Completed
Push — master ( ff4f9b...44b6f8 )
by Alexander
02:12
created

TextReporter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 50
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
B generate() 0 28 5
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 TextReporter extends AbstractReporter
15
{
16
17
	/**
18
	 * Returns reporter name.
19
	 *
20
	 * @return string
21
	 */
22
	public function getName()
23
	{
24
		return 'text';
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 'No backwards compatibility breaks detected.';
38
		}
39
40
		$ret = 'Backward compatibility breaks:' . PHP_EOL;
41
42
		foreach ( $this->groupByType($bc_breaks) as $bc_break => $incidents ) {
43
			$ret .= PHP_EOL;
44
45
			$bc_break = ucwords(str_replace(array('.', '_'), ' ', $bc_break));
46
			$ret .= '<fg=red>=== ' . $bc_break . ' (' . count($incidents) . ') ===</>' . PHP_EOL;
47
48
			foreach ( $incidents as $incident_data ) {
49
				if ( array_key_exists('old', $incident_data) ) {
50
					$ret .= ' * <fg=white;options=bold>' . $incident_data['element'] . '</>' . PHP_EOL;
51
					$ret .= '   OLD: ' . $incident_data['old'] . PHP_EOL;
52
					$ret .= '   NEW: ' . $incident_data['new'] . PHP_EOL;
53
				}
54
				else {
55
					$ret .= ' * ' . $incident_data['element'] . PHP_EOL;
56
				}
57
			}
58
		}
59
60
		return $ret;
61
	}
62
63
}
64