|
7 | 7 | namespace DVDoug\Behat\CodeCoverage\Service;
|
8 | 8 |
|
9 | 9 | use Composer\InstalledVersions;
|
10 |
| -use Composer\Semver\VersionParser; |
11 | 10 | use SebastianBergmann\CodeCoverage\CodeCoverage;
|
12 | 11 | use SebastianBergmann\CodeCoverage\Report\Clover;
|
13 | 12 | use SebastianBergmann\CodeCoverage\Report\Cobertura;
|
@@ -54,65 +53,44 @@ public function generateReport(CodeCoverage $coverage): void
|
54 | 53 | $report->process($coverage, $config['target'], $config['name']);
|
55 | 54 | break;
|
56 | 55 | case 'html':
|
57 |
| - if (InstalledVersions::satisfies(new VersionParser(), 'phpunit/php-code-coverage', '^9.0')) { |
58 |
| - $report = new HtmlFacade( |
59 |
| - $config['lowUpperBound'], |
60 |
| - $config['highLowerBound'], |
61 |
| - sprintf( |
62 |
| - ' and <a href="https://behat.cc">Behat Code Coverage %s</a>', |
63 |
| - InstalledVersions::getPrettyVersion('dvdoug/behat-code-coverage') |
64 |
| - ) |
65 |
| - ); |
| 56 | + $thresholds = Thresholds::from( |
| 57 | + $config['lowUpperBound'], |
| 58 | + $config['highLowerBound'], |
| 59 | + ); |
| 60 | + $colors = Colors::from( |
| 61 | + $config['colors']['successLow'], |
| 62 | + $config['colors']['successMedium'], |
| 63 | + $config['colors']['successHigh'], |
| 64 | + $config['colors']['warning'], |
| 65 | + $config['colors']['danger'], |
| 66 | + ); |
| 67 | + if ($config['customCSSFile']) { |
| 68 | + $customCss = CustomCssFile::from($config['customCSSFile']); |
66 | 69 | } else {
|
67 |
| - $thresholds = Thresholds::from( |
68 |
| - $config['lowUpperBound'], |
69 |
| - $config['highLowerBound'], |
70 |
| - ); |
71 |
| - $colors = Colors::from( |
72 |
| - $config['colors']['successLow'], |
73 |
| - $config['colors']['successMedium'], |
74 |
| - $config['colors']['successHigh'], |
75 |
| - $config['colors']['warning'], |
76 |
| - $config['colors']['danger'], |
77 |
| - ); |
78 |
| - if ($config['customCSSFile']) { |
79 |
| - $customCss = CustomCssFile::from($config['customCSSFile']); |
80 |
| - } else { |
81 |
| - $customCss = CustomCssFile::default(); |
82 |
| - } |
83 |
| - $report = new HtmlFacade( |
84 |
| - sprintf( |
85 |
| - ' and <a href="https://behat.cc">Behat Code Coverage %s</a>', |
86 |
| - InstalledVersions::getPrettyVersion('dvdoug/behat-code-coverage') |
87 |
| - ), |
88 |
| - $colors, |
89 |
| - $thresholds, |
90 |
| - $customCss |
91 |
| - ); |
| 70 | + $customCss = CustomCssFile::default(); |
92 | 71 | }
|
| 72 | + $report = new HtmlFacade( |
| 73 | + sprintf( |
| 74 | + ' and <a href="https://behat.cc">Behat Code Coverage %s</a>', |
| 75 | + InstalledVersions::getPrettyVersion('dvdoug/behat-code-coverage') |
| 76 | + ), |
| 77 | + $colors, |
| 78 | + $thresholds, |
| 79 | + $customCss |
| 80 | + ); |
93 | 81 | $report->process($coverage, $config['target']);
|
94 | 82 | break;
|
95 | 83 | case 'text':
|
96 |
| - if (InstalledVersions::satisfies(new VersionParser(), 'phpunit/php-code-coverage', '^9.0')) { |
97 |
| - $report = new Text( |
98 |
| - $config['lowUpperBound'], |
99 |
| - $config['highLowerBound'], |
100 |
| - $config['showUncoveredFiles'], |
101 |
| - $config['showOnlySummary'] |
102 |
| - ); |
103 |
| - echo $report->process($coverage, $config['showColors']); |
104 |
| - } else { |
105 |
| - $thresholds = Thresholds::from( |
106 |
| - $config['lowUpperBound'], |
107 |
| - $config['highLowerBound'], |
108 |
| - ); |
109 |
| - $report = new Text( |
110 |
| - $thresholds, |
111 |
| - $config['showUncoveredFiles'], |
112 |
| - $config['showOnlySummary'] |
113 |
| - ); |
114 |
| - echo $report->process($coverage, $config['showColors']); |
115 |
| - } |
| 84 | + $thresholds = Thresholds::from( |
| 85 | + $config['lowUpperBound'], |
| 86 | + $config['highLowerBound'], |
| 87 | + ); |
| 88 | + $report = new Text( |
| 89 | + $thresholds, |
| 90 | + $config['showUncoveredFiles'], |
| 91 | + $config['showOnlySummary'] |
| 92 | + ); |
| 93 | + echo $report->process($coverage, $config['showColors']); |
116 | 94 | break;
|
117 | 95 | case 'xml':
|
118 | 96 | $report = new XmlFacade('');
|
|
0 commit comments