TraitPublicMethod::apply()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 3
eloc 3
nc 2
nop 1
crap 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