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

ConstantChecker::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
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