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
|
|
|
abstract class AbstractReporter |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Returns reporter name. |
19
|
|
|
* |
20
|
|
|
* @return string |
21
|
|
|
*/ |
22
|
|
|
abstract public function getName(); |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Generates report. |
26
|
|
|
* |
27
|
|
|
* @param array $bc_breaks BC breaks. |
28
|
|
|
* |
29
|
|
|
* @return string |
30
|
|
|
*/ |
31
|
|
|
abstract public function generate(array $bc_breaks); |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Groups BC breaks by type. |
35
|
|
|
* |
36
|
|
|
* @param array $bc_breaks BC breaks. |
37
|
|
|
* |
38
|
|
|
* @return array |
39
|
|
|
*/ |
40
|
|
|
protected function groupByType(array $bc_breaks) |
41
|
|
|
{ |
42
|
|
|
$ret = array(); |
43
|
|
|
|
44
|
|
|
foreach ( $bc_breaks as $bc_break_data ) { |
45
|
|
|
$type = $bc_break_data['type']; |
46
|
|
|
|
47
|
|
|
if ( !isset($ret[$type]) ) { |
48
|
|
|
$ret[$type] = array(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$ret[$type][] = $bc_break_data; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $ret; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Sorts BC breaks by element. |
59
|
|
|
* |
60
|
|
|
* @param array $bc_breaks BC breaks. |
61
|
|
|
* |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
|
|
protected function sortByElement(array $bc_breaks) |
65
|
|
|
{ |
66
|
|
|
usort($bc_breaks, array($this, 'sortByElementCallback')); |
67
|
|
|
|
68
|
|
|
return $bc_breaks; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Sorts BC breaks by element. |
73
|
|
|
* |
74
|
|
|
* @param array $incident_a Incident A. |
75
|
|
|
* @param array $incident_b Incident B. |
76
|
|
|
* |
77
|
|
|
* @return integer |
78
|
|
|
*/ |
79
|
|
|
public function sortByElementCallback(array $incident_a, array $incident_b) |
80
|
|
|
{ |
81
|
|
|
return strcmp($incident_a['element'], $incident_b['element']); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|