@@ -29,7 +29,19 @@ public function run(Arguments $arguments): int
29
29
return 1 ;
30
30
}
31
31
32
- $ filter = new Filter ;
32
+ if (!$ arguments ->reportConfigured ()) {
33
+ print 'No code coverage report configured ' . PHP_EOL ;
34
+
35
+ return 1 ;
36
+ }
37
+
38
+ $ filter = $ this ->createFilter ($ arguments );
39
+
40
+ if ($ filter ->isEmpty ()) {
41
+ print 'No list of files to be included in code coverage configured ' . PHP_EOL ;
42
+
43
+ return 1 ;
44
+ }
33
45
34
46
try {
35
47
if ($ arguments ->pathCoverage ()) {
@@ -45,20 +57,8 @@ public function run(Arguments $arguments): int
45
57
return 1 ;
46
58
}
47
59
60
+ $ this ->configureCodeCoverageCollection ($ coverage , $ arguments );
48
61
$ this ->handleConfiguration ($ coverage , $ arguments );
49
- $ this ->handleFilter ($ coverage , $ arguments );
50
-
51
- if ($ filter ->isEmpty ()) {
52
- print 'No list of files to be included in code coverage configured ' . PHP_EOL ;
53
-
54
- return 1 ;
55
- }
56
-
57
- if (!$ arguments ->reportConfigured ()) {
58
- print 'No code coverage report configured ' . PHP_EOL ;
59
-
60
- return 1 ;
61
- }
62
62
63
63
$ coverage ->start ('phpcov ' );
64
64
@@ -72,7 +72,22 @@ public function run(Arguments $arguments): int
72
72
return 0 ;
73
73
}
74
74
75
- private function handleFilter (CodeCoverage $ coverage , Arguments $ arguments ): void
75
+ private function createFilter (Arguments $ arguments ): Filter
76
+ {
77
+ $ filter = new Filter ;
78
+
79
+ foreach ($ arguments ->include () as $ item ) {
80
+ if (is_dir ($ item )) {
81
+ $ filter ->includeDirectory ($ item );
82
+ } elseif (is_file ($ item )) {
83
+ $ filter ->includeFile ($ item );
84
+ }
85
+ }
86
+
87
+ return $ filter ;
88
+ }
89
+
90
+ private function configureCodeCoverageCollection (CodeCoverage $ coverage , Arguments $ arguments ): void
76
91
{
77
92
if ($ arguments ->addUncovered ()) {
78
93
$ coverage ->includeUncoveredFiles ();
@@ -85,13 +100,5 @@ private function handleFilter(CodeCoverage $coverage, Arguments $arguments): voi
85
100
} else {
86
101
$ coverage ->doNotProcessUncoveredFiles ();
87
102
}
88
-
89
- foreach ($ arguments ->include () as $ item ) {
90
- if (is_dir ($ item )) {
91
- $ coverage ->filter ()->includeDirectory ($ item );
92
- } elseif (is_file ($ item )) {
93
- $ coverage ->filter ()->includeFile ($ item );
94
- }
95
- }
96
103
}
97
104
}
0 commit comments