Completed
Push — master ( e29708...306776 )
by T
02:29
created

ClassMethodOperationDelta   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
lcom 2
cbo 4
dl 0
loc 109
ccs 18
cts 22
cp 0.8182
rs 10
c 1
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
A getLocation() 0 4 1
A getLine() 0 4 1
A getTarget() 0 4 1
A getCode() 0 4 1
A getReason() 0 4 1
A getVisibility() 0 4 1
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
	 * @var string
12
	 */
13
	protected $context;
14
	/**
15
	 * @var int
16
	 */
17
	protected $visibility;
18
	/**
19
	 * @var string
20
	 */
21
	protected $fileBefore;
22
	/**
23
	 * @var \PhpParser\Node\Stmt
24
	 */
25
	protected $contextBefore;
26
	/**
27
	 * @var \PhpParser\Node\Stmt\ClassMethod
28
	 */
29
	protected $classMethodBefore;
30
	/**
31
	 * @var string
32
	 */
33
	protected $fileAfter;
34
	/**
35
	 * @var \PhpParser\Node\Stmt
36
	 */
37
	protected $contextAfter;
38
	/**
39
	 * @var \PhpParser\Node\Stmt\ClassMethod
40
	 */
41
	protected $classMethodAfter;
42
43
	/**
44
	 * @param string                           $context
45
	 * @param string                           $fileBefore
46
	 * @param \PhpParser\Node\Stmt             $contextBefore
47
	 * @param \PhpParser\Node\Stmt\ClassMethod $classMethodBefore
48
	 * @param string                           $fileAfter
49
	 * @param \PhpParser\Node\Stmt             $contextAfter
50
	 * @param \PhpParser\Node\Stmt\ClassMethod $classMethodAfter
51
	 */
52 20
	public function __construct($context,
53
								$fileBefore,
54
								Stmt $contextBefore,
55
								ClassMethod $classMethodBefore,
56
								$fileAfter,
57
								Stmt $contextAfter,
58
								ClassMethod $classMethodAfter)
59
	{
60 20
		$this->context = $context;
61 20
		$this->visibility = $this->getVisibility($classMethodAfter);
62 20
		$this->fileBefore = $fileBefore;
63 20
		$this->contextBefore = $contextBefore;
64 20
		$this->classMethodBefore = $classMethodBefore;
65 20
		$this->fileAfter = $fileAfter;
66 20
		$this->contextAfter = $contextAfter;
67 20
		$this->classMethodAfter = $classMethodAfter;
68 20
	}
69
70
	/**
71
	 * @return string
72
	 */
73
	public function getLocation()
74
	{
75
		return $this->fileAfter;
76
	}
77
78
	/**
79
	 * @return int
80
	 */
81
	public function getLine()
82
	{
83
		return $this->classMethodAfter->getLine();
84
	}
85
86
	/**
87
	 * @return string
88
	 */
89 20
	public function getTarget()
90
	{
91 20
		return PClassMethod::getFullyQualifiedName($this->contextAfter, $this->classMethodAfter);
92
	}
93
94
	/**
95
	 * @return string
96
	 */
97 20
	public function getCode()
98
	{
99 20
		return $this->code[$this->context][Visibility::get($this->visibility)];
100
	}
101
102
	/**
103
	 * @return string
104
	 */
105 20
	public function getReason()
106
	{
107 20
		return '[' . Visibility::toString($this->visibility) . '] ' . $this->reason;
108
	}
109
110
	/**
111
	 * @return string
112
	 */
113 20
	protected function getVisibility($context)
114
	{
115 20
		return Visibility::getForContext($context);
116
	}
117
}
118