Completed
Push — master ( 0e1c32...e580ff )
by T
05:02
created

PropertyAdded::getLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace PHPSemVerChecker\Operation;
4
5
use PhpParser\Node\Stmt;
6
use PhpParser\Node\Stmt\Property;
7
use PHPSemVerChecker\Node\Statement\Property as PProperty;
8
9
class PropertyAdded extends PropertyOperation {
10
	/**
11
	 * @var array
12
	 */
13
	protected $code = [
14
		'class' => ['V019', 'V020', 'V026'],
15
		'trait' => ['V049', 'V050', 'V055'],
16
	];
17
	/**
18
	 * @var string
19
	 */
20
	protected $reason = 'Property has been added.';
21
	/**
22
	 * @var string
23
	 */
24
	protected $fileAfter;
25
	/**
26
	 * @var \PhpParser\Node\Stmt
27
	 */
28
	protected $contextAfter;
29
	/**
30
	 * @var \PhpParser\Node\Stmt\Property
31
	 */
32
	protected $propertyAfter;
33
34
	/**
35
	 * @param string                        $context
36
	 * @param string                        $fileAfter
37
	 * @param \PhpParser\Node\Stmt          $contextAfter
38
	 * @param \PhpParser\Node\Stmt\Property $propertyAfter
39
	 */
40 2
	public function __construct($context, $fileAfter, Stmt $contextAfter, Property $propertyAfter)
41
	{
42 2
		$this->context = $context;
43 2
		$this->visibility = $this->getVisibility($propertyAfter);
44 2
		$this->fileAfter = $fileAfter;
45 2
		$this->contextAfter = $contextAfter;
46 2
		$this->propertyAfter = $propertyAfter;
47 2
	}
48
49
	/**
50
	 * @return string
51
	 */
52
	public function getLocation()
53
	{
54
		return $this->fileAfter;
55
	}
56
57
	/**
58
	 * @return int
59
	 */
60
	public function getLine()
61
	{
62
		return $this->propertyAfter->getLine();
63
	}
64
65
	/**
66
	 * @return string
67
	 */
68 2
	public function getTarget()
69
	{
70 2
		return PProperty::getFullyQualifiedName($this->contextAfter, $this->propertyAfter);
71
	}
72
}
73