Completed
Push — master ( 1cdbe4...17a825 )
by T
02:03
created

InterfaceOperationDelta   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 98.18 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 54
loc 55
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getLocation() 4 4 1
A getLine() 4 4 1
A getTarget() 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\Interface_;
6
use PHPSemVerChecker\Node\Statement\Interface_ as PInterface;
7
8 View Code Duplication
class InterfaceOperationDelta 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
	/**
11
	 * @var string
12
	 */
13
	protected $fileBefore;
14
	/**
15
	 * @var \PhpParser\Node\Stmt\Interface_
16
	 */
17
	protected $interfaceBefore;
18
	/**
19
	 * @var string
20
	 */
21
	protected $fileAfter;
22
	/**
23
	 * @var \PhpParser\Node\Stmt\Interface_
24
	 */
25
	protected $interfaceAfter;
26
27
	/**
28
	 * @param string                          $fileAfter
29
	 * @param \PhpParser\Node\Stmt\Interface_ $interface
0 ignored issues
show
Documentation introduced by
There is no parameter named $interface. Did you maybe mean $interfaceBefore?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
30
	 */
31 1
	public function __construct($fileBefore, Interface_ $interfaceBefore, $fileAfter, Interface_ $interfaceAfter)
32
	{
33 1
		$this->fileBefore = $fileBefore;
34 1
		$this->interfaceBefore = $interfaceBefore;
35 1
		$this->fileAfter = $fileAfter;
36 1
		$this->interfaceAfter = $interfaceAfter;
37 1
	}
38
39
	/**
40
	 * @return string
41
	 */
42
	public function getLocation()
43
	{
44
		return $this->fileAfter;
45
	}
46
47
	/**
48
	 * @return int
49
	 */
50
	public function getLine()
51
	{
52
		return $this->interfaceAfter->getLine();
53
	}
54
55
	/**
56
	 * @return string
57
	 */
58
	public function getTarget()
59
	{
60
		return PInterface::getFullyQualifiedName($this->interfaceAfter);
61
	}
62
}
63