GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( b66988...b99575 )
by Michael
04:21
created

ControllerMethodName   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 94.44%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 44
ccs 17
cts 18
cp 0.9444
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 16 4
A isController() 0 16 4
1
<?php
2
3
namespace MS\PHPMD\Rule\Naming;
4
5
use PHPMD\AbstractNode;
6
use PHPMD\AbstractRule;
7
use PHPMD\Node\ClassNode;
8
use PHPMD\Node\MethodNode;
9
use PHPMD\Rule\MethodAware;
10
11
/**
12
 * When the class is concrete and ends with Controller, the method names have to end with Action.
13
 */
14
class ControllerMethodName extends AbstractRule implements MethodAware
15
{
16
    /**
17
     * @param AbstractNode|MethodNode $node
18
     */
19 6
    public function apply(AbstractNode $node)
20
    {
21 6
        if (false === $this->isController($node->getParentType())) {
22 4
            return;
23
        }
24
25 2
        $allowedMethodNames = explode($this->getStringProperty('delimiter'), $this->getStringProperty('allowedMethodNames'));
26
27 2
        if (true === in_array($node->getImage(), $allowedMethodNames)) {
28 2
            return;
29
        }
30
31 2
        if ('Action' !== substr($node->getImage(), -6, 6)) {
32 2
            $this->addViolation($node);
33 2
        }
34 2
    }
35
36
    /**
37
     * @param AbstractNode $node
38
     *
39
     * @return bool
40
     */
41 6
    private function isController(AbstractNode $node)
42
    {
43 6
        if (false === $node instanceof ClassNode) {
44
            return false;
45
        }
46
47 6
        if (true === $node->isAbstract()) {
48 1
            return false;
49
        }
50
51 5
        if ('Controller' === substr($node->getImage(), -10, 10)) {
52 2
            return true;
53
        }
54
55 3
        return false;
56
    }
57
}
58