TraitPublicMethod   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
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 12
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 6 3
1
<?php
2
3
namespace MS\PHPMD\Rule\CleanCode;
4
5
use PDepend\Source\AST\ASTMethod;
6
use PHPMD\AbstractNode;
7
use PHPMD\AbstractRule;
8
use PHPMD\Node\MethodNode;
9
use PHPMD\Node\TraitNode;
10
use PHPMD\Rule\MethodAware;
11
12
/**
13
 * Class TraitPublicMethod
14
 *
15
 * The purpose of a trait should be the reuse of methods which help the basic classes. Make your code clearly and define interfaces of your class as public methods.
16
 *
17
 * @package MS\PHPMD\Rule\CleanCode
18
 */
19
class TraitPublicMethod extends AbstractRule implements MethodAware
20
{
21
    /**
22
     * @param AbstractNode|MethodNode|ASTMethod $node
23
     */
24 3
    public function apply(AbstractNode $node)
25
    {
26 3
        if ($node->getParentType() instanceof TraitNode && true === $node->isPublic()) {
27 1
            $this->addViolation($node);
28 1
        }
29 3
    }
30
}
31