Failed Conditions
Push — master ( e02dc1...26605a )
by Alexander
01:39
created

ConstantChecker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 44
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getName() 0 4 1
A doCheck() 0 14 3
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;
12
13
14
class ConstantChecker extends AbstractChecker
15
{
16
17
	/**
18
	 * ConstantChecker constructor.
19
	 */
20
	public function __construct()
21
	{
22
		$this->defineIncidentGroups(array(
23
			'Constant Deleted',
24
		));
25
	}
26
27
	/**
28
	 * Returns backwards compatibility checker name.
29
	 *
30
	 * @return string
31
	 */
32
	public function getName()
33
	{
34
		return 'constant';
35
	}
36
37
	/**
38
	 * Collects backwards compatibility violations.
39
	 *
40
	 * @return void
41
	 */
42
	protected function doCheck()
43
	{
44
		$sql = 'SELECT Name
45
				FROM Constants';
46
		$source_constants = $this->sourceDatabase->fetchCol($sql);
47
		$target_constants = $this->targetDatabase->fetchCol($sql);
48
49
		foreach ( $source_constants as $source_constant_name ) {
50
			if ( !in_array($source_constant_name, $target_constants) ) {
51
				$this->addIncident('Constant Deleted', $source_constant_name);
52
				continue;
53
			}
54
		}
55
	}
56
57
}
58