EntityConstants   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 10 3
1
<?php
2
3
namespace MS\PHPMD\Rule\Symfony2;
4
5
use PDepend\Source\AST\ASTClass;
6
use PHPMD\AbstractNode;
7
use PHPMD\Node\ClassNode;
8
9
/**
10
 * Class EntityConstants
11
 *
12
 * Don't contain constants in your entity. Important information are distribute throughout the project. You reduce the reusability.
13
 *
14
 * @package MS\PHPMD\Rule\Symfony2
15
 */
16
class EntityConstants extends AbstractEntityRule
17
{
18
    /**
19
     * @param AbstractNode|ClassNode|ASTClass $node
20
     */
21 2
    public function apply(AbstractNode $node)
22
    {
23 2
        if (false === $this->isEntity($node)) {
0 ignored issues
show
Compatibility introduced by
$node of type object<PHPMD\AbstractNode> is not a sub-type of object<PHPMD\Node\ClassNode>. It seems like you assume a child class of the class PHPMD\AbstractNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
24 1
            return;
25
        }
26
27 1
        if (0 !== count($node->getConstants())) {
28 1
            $this->addViolation($node);
29 1
        }
30 1
    }
31
}
32