Completed
Pull Request — master (#82)
by Graham
15:21 queued 09:41
created

FunctionParameterNameChanged   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 1
cbo 3
dl 64
loc 64
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getTarget() 4 4 1
A getLocation() 4 4 1
A getLine() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace PHPSemVerChecker\Operation;
4
5
use PhpParser\Node\Stmt\Function_;
6
use PHPSemVerChecker\Node\Statement\Function_ as PFunction;
7
8 View Code Duplication
class FunctionParameterNameChanged extends Operation {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
	/**
10
	 * @var string
11
	 */
12
	protected $code = 'V067';
13
	/**
14
	 * @var string
15
	 */
16
	protected $reason = 'Function parameter name changed.';
17
	/**
18
	 * @var string
19
	 */
20
	protected $fileBefore;
21
	/**
22
	 * @var \PhpParser\Node\Stmt\Function_
23
	 */
24
	protected $functionBefore;
25
	/**
26
	 * @var string
27
	 */
28
	protected $fileAfter;
29
	/**
30
	 * @var \PhpParser\Node\Stmt\Function_
31
	 */
32
	protected $functionAfter;
33
34
	/**
35
	 * @param string                         $fileBefore
36
	 * @param \PhpParser\Node\Stmt\Function_ $functionBefore
37
	 * @param string                         $fileAfter
38
	 * @param \PhpParser\Node\Stmt\Function_ $functionAfter
39
	 */
40 1
	public function __construct($fileBefore, Function_ $functionBefore, $fileAfter, Function_ $functionAfter)
41
	{
42 1
		$this->fileBefore = $fileBefore;
43 1
		$this->functionBefore = $functionBefore;
44 1
		$this->fileAfter = $fileAfter;
45 1
		$this->functionAfter = $functionAfter;
46 1
	}
47
48
	/**
49
	 * @return string
50
	 */
51
	public function getLocation()
52
	{
53
		return $this->fileBefore;
54
	}
55
56
	/**
57
	 * @return int
58
	 */
59
	public function getLine()
60
	{
61
		return $this->functionAfter->getLine();
62
	}
63
64
	/**
65
	 * @return string
66
	 */
67 1
	public function getTarget()
68
	{
69 1
		return PFunction::getFullyQualifiedName($this->functionAfter);
70
	}
71
}
72