Defect   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLine() 0 4 1
A getNode() 0 4 1
A getContext() 0 9 2
A setContext() 0 6 1
getMessage() 0 1 ?
1
<?php
2
3
namespace Solidifier;
4
5
use PhpParser\Node;
6
7
abstract class Defect extends Event
8
{
9
    const
10
        EVENT_NAME = 'defect';    
11
    
12
    protected
13
        $node,
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
Coding Style introduced by
The visibility should be declared for property $node.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
14
        $context;
15
    
16
    public function __construct(Node $node)
17
    {
18
        $this->node = $node;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
19
        $this->context = null;
20
    }
21
            
22
    public function getLine()
23
    {
24
        return $this->node->getLine();    
25
    }
26
    
27
    public function getNode()
28
    {
29
        return $this->node;
30
    }
31
32
    public function getContext()
33
    {
34
        if($this->context instanceof Node)
35
        {
36
            return $this->context;
37
        }
38
        
39
        return $this->node;
40
    }
41
    
42
    public function setContext(Node $contextNode)
43
    {
44
        $this->context = $contextNode;
45
        
46
        return $this;
47
    }
48
    
49
    abstract public function getMessage();
50
}