Completed
Push — master ( 77231c...ff4f9b )
by Alexander
03:22
created

ConstantChecker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 36
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
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\Checker;
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