PublicAttribute::getMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Solidifier\Defects;
4
5
use Solidifier\Defect;
6
use Solidifier\Visitors\ObjectType;
7
use PhpParser\Node\Stmt\Property;
8
9 View Code Duplication
class PublicAttribute extends Defect
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...
10
{
11
    private
12
        $objectType,
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 $objectType.

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
        $property;
14
        
15
    public function __construct(ObjectType $objectType, $property, Property $node)
16
    {
17
        parent::__construct($node);
18
19
        $this->objectType = $objectType;    
20
        $this->property = $property;    
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
21
    }    
22
    
23
    public function getMessage()
24
    {
25
        return sprintf(
26
            'Public property <id>%s</id> in %s <type>%s</type>',
27
            $this->property,
28
            $this->objectType->type,
29
            $this->objectType->fullname
30
        );
31
    }
32
}
33