Completed
Push — master ( bc9a8a...77231c )
by Alexander
04:23
created

ConstantChecker::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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
	const TYPE_CONSTANT_DELETED = 'constant.deleted';
18
19
	/**
20
	 * Returns backwards compatibility checker name.
21
	 *
22
	 * @return string
23
	 */
24 1
	public function getName()
25
	{
26 1
		return 'constant';
27
	}
28
29
	/**
30
	 * Collects backwards compatibility violations.
31
	 *
32
	 * @return void
33
	 */
34 2
	protected function doCheck()
35
	{
36
		$sql = 'SELECT Name
37 2
				FROM Constants';
38 2
		$source_constants = $this->sourceDatabase->fetchCol($sql);
39 2
		$target_constants = $this->targetDatabase->fetchCol($sql);
40
41 2
		foreach ( $source_constants as $source_constant_name ) {
42 2
			if ( !in_array($source_constant_name, $target_constants) ) {
43 1
				$this->addIncident(self::TYPE_CONSTANT_DELETED, $source_constant_name);
44 1
				continue;
45
			}
46 2
		}
47 2
	}
48
49
}
50