EncapsulationViolation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getMessage() 0 7 1
1
<?php
2
3
namespace Solidifier\Defects;
4
5
use Solidifier\Defect;
6
use PhpParser\PrettyPrinter\Standard;
7
use PhpParser\Node\Stmt\Property;
8
9
class EncapsulationViolation extends Defect
10
{
11
    private
12
        $propertyName;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $propertyName.

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...
13
    
14
    public function __construct($propertyName, Property $node)
15
    {
16
        parent::__construct($node);
17
    
18
        $this->propertyName = $propertyName;
19
    }
20
    
21
    public function getMessage()
22
    {
23
        return sprintf(
24
            'Both public getter and setter on private property <id>%s</id> is discouraged (encapsulation violation) ',
25
            $this->propertyName
26
        );
27
    }
28
}
29