ClassMethodOperationDelta::getLocation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace PHPSemVerChecker\Operation;
4
5
use PhpParser\Node\Stmt;
6
use PhpParser\Node\Stmt\ClassMethod;
7
use PHPSemVerChecker\Node\Statement\ClassMethod as PClassMethod;
8
9
abstract class ClassMethodOperationDelta extends Operation
10
{
11
	/**
12
	 * @var string
13
	 */
14
	protected $context;
15
	/**
16
	 * @var int
17
	 */
18
	protected $visibility;
19
	/**
20
	 * @var string
21
	 */
22
	protected $fileBefore;
23
	/**
24
	 * @var \PhpParser\Node\Stmt
25
	 */
26
	protected $contextBefore;
27
	/**
28
	 * @var \PhpParser\Node\Stmt\ClassMethod
29
	 */
30
	protected $classMethodBefore;
31
	/**
32
	 * @var string
33
	 */
34
	protected $fileAfter;
35
	/**
36
	 * @var \PhpParser\Node\Stmt
37
	 */
38
	protected $contextAfter;
39
	/**
40
	 * @var \PhpParser\Node\Stmt\ClassMethod
41
	 */
42
	protected $classMethodAfter;
43
44
	/**
45
	 * @param string                           $context
46
	 * @param string                           $fileBefore
47
	 * @param \PhpParser\Node\Stmt             $contextBefore
48
	 * @param \PhpParser\Node\Stmt\ClassMethod $classMethodBefore
49
	 * @param string                           $fileAfter
50
	 * @param \PhpParser\Node\Stmt             $contextAfter
51
	 * @param \PhpParser\Node\Stmt\ClassMethod $classMethodAfter
52
	 */
53 26
	public function __construct($context,
54
								$fileBefore,
55
								Stmt $contextBefore,
56
								ClassMethod $classMethodBefore,
57
								$fileAfter,
58
								Stmt $contextAfter,
59
								ClassMethod $classMethodAfter)
60
	{
61 26
		$this->context = $context;
62 26
		$this->visibility = $this->getVisibility($classMethodAfter);
63 26
		$this->fileBefore = $fileBefore;
64 26
		$this->contextBefore = $contextBefore;
65 26
		$this->classMethodBefore = $classMethodBefore;
66 26
		$this->fileAfter = $fileAfter;
67 26
		$this->contextAfter = $contextAfter;
68 26
		$this->classMethodAfter = $classMethodAfter;
69 26
	}
70
71
	/**
72
	 * @return string
73
	 */
74
	public function getLocation()
75
	{
76
		return $this->fileAfter;
77
	}
78
79
	/**
80
	 * @return int
81
	 */
82
	public function getLine()
83
	{
84
		return $this->classMethodAfter->getLine();
85
	}
86
87
	/**
88
	 * @return string
89
	 */
90 20
	public function getTarget()
91
	{
92 20
		return PClassMethod::getFullyQualifiedName($this->contextAfter, $this->classMethodAfter);
93
	}
94
95
	/**
96
	 * @return string
97
	 */
98 26
	public function getCode()
99
	{
100 26
		return $this->code[$this->context][Visibility::get($this->visibility)];
101
	}
102
103
	/**
104
	 * @return string
105
	 */
106 26
	public function getReason()
107
	{
108 26
		return '[' . Visibility::toString($this->visibility) . '] ' . $this->reason;
109
	}
110
111
	/**
112
	 * @param mixed $context
113
	 * @return int
114
	 */
115 26
	protected function getVisibility($context)
116
	{
117 26
		return Visibility::getForContext($context);
118
	}
119
}
120