1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Code-Insight library. |
4
|
|
|
* For the full copyright and license information, please view |
5
|
|
|
* the LICENSE file that was distributed with this source code. |
6
|
|
|
* |
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
8
|
|
|
* @link https://github.com/console-helpers/code-insight |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
class HtmlReporter extends AbstractReporter |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Returns reporter name. |
19
|
|
|
* |
20
|
|
|
* @return string |
21
|
|
|
*/ |
22
|
|
|
public function getName() |
23
|
|
|
{ |
24
|
|
|
return 'html'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Generates report. |
29
|
|
|
* |
30
|
|
|
* @param array $bc_breaks BC breaks. |
31
|
|
|
* |
32
|
|
|
* @return string |
33
|
|
|
*/ |
34
|
|
|
public function generate(array $bc_breaks) |
35
|
|
|
{ |
36
|
|
|
if ( !$bc_breaks ) { |
37
|
|
|
return '<h1>No backwards compatibility breaks detected.</h1>'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$ret = <<<HTML |
41
|
|
|
<html> |
42
|
|
|
<head> |
43
|
|
|
<style type="text/css"> |
44
|
|
|
ol.bc-report { font-family: monospace; } |
45
|
|
|
ol.bc-report li { padding: 4px; margin-bottom: 8px; } |
46
|
|
|
ol.bc-report li:nth-child(odd) { background-color: lightgray; } |
47
|
|
|
</style> |
48
|
|
|
</head> |
49
|
|
|
<body> |
50
|
|
|
<h1>Backward compatibility breaks:</h1> |
51
|
|
|
HTML; |
52
|
|
|
|
53
|
|
|
foreach ( $this->groupByType($bc_breaks) as $bc_break => $incidents ) { |
54
|
|
|
$ret .= PHP_EOL; |
55
|
|
|
|
56
|
|
|
$bc_break = ucwords(str_replace(array('.', '_'), ' ', $bc_break)); |
57
|
|
|
$ret .= "\t\t" . '<h2>' . $bc_break . ' (' . count($incidents) . ')</h2>' . PHP_EOL; |
58
|
|
|
$ret .= "\t\t" . '<ol class="bc-report">' . PHP_EOL; |
59
|
|
|
|
60
|
|
|
foreach ( $incidents as $incident_data ) { |
61
|
|
|
if ( array_key_exists('old', $incident_data) ) { |
62
|
|
|
$ret .= "\t\t\t" . '<li>' . PHP_EOL; |
63
|
|
|
$ret .= "\t\t\t\t" . '<strong>' . $incident_data['element'] . '</strong><br/>' . PHP_EOL; |
64
|
|
|
$ret .= "\t\t\t\t" . 'OLD: ' . $incident_data['old'] . '<br/>' . PHP_EOL; |
65
|
|
|
$ret .= "\t\t\t\t" . 'NEW: ' . $incident_data['new'] . '<br/>' . PHP_EOL; |
66
|
|
|
$ret .= "\t\t\t" . '</li>' . PHP_EOL; |
67
|
|
|
} |
68
|
|
|
else { |
69
|
|
|
$ret .= "\t\t\t" . '<li>' . $incident_data['element'] . '</li>' . PHP_EOL; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$ret .= "\t\t" . '</ol>'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$ret .= PHP_EOL; |
77
|
|
|
$ret .= "\t" . '</body>' . PHP_EOL; |
78
|
|
|
$ret .= '</html>' . PHP_EOL; |
79
|
|
|
|
80
|
|
|
return $ret; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
|