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.
Test Failed
Push — master ( ea3c3c...758782 )
by Michael
03:51
created

ReturnStatement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 17 4
A getAllowedClasses() 0 10 2
1
<?php
2
3
namespace MS\PHPMD\Rule\CleanCode;
4
5
use PDepend\Source\AST\ASTReturnStatement;
6
use PHPMD\AbstractNode;
7
use PHPMD\AbstractRule;
8
use PHPMD\Node\MethodNode;
9
use PHPMD\Rule\MethodAware;
10
11
/**
12
 * To easy understand a return statement line, it should only have simple allocations.
13
 * Don't write your logical code in the return line.
14
 */
15
class ReturnStatement extends AbstractRule implements MethodAware
16
{
17
    /**
18
     * @param AbstractNode|MethodNode $node
19
     */
20
    public function apply(AbstractNode $node)
21
    {
22
        $allowedChildren = $this->getStringProperty('allowedChildren');
23
        $allowedClasses = $this->getAllowedClasses($allowedChildren);
24
        $returnStatements = $node->findChildrenOfType('ReturnStatement');
25
26
        /** @var AbstractNode|ASTReturnStatement $returnStatement */
27
        foreach ($returnStatements as $returnStatement) {
28
            foreach ($returnStatement->getChildren() as $child) {
29
                $reflectChild = new \ReflectionClass($child);
30
31
                if (false === in_array($reflectChild->getShortName(), $allowedClasses)) {
32
                    $this->addViolation($returnStatement, [$allowedChildren]);
33
                }
34
            }
35
        }
36
    }
37
38
    /**
39
     * @param string $allowedChildren
40
     *
41
     * @return array
42
     */
43
    private function getAllowedClasses($allowedChildren)
44
    {
45
        $allowedClasses = explode($this->getStringProperty('delimiter'), $allowedChildren);
46
47
        foreach ($allowedClasses as &$allowedClass) {
48
            $allowedClass = 'AST'.$allowedClass;
49
        }
50
51
        return $allowedClasses;
52
    }
53
}
54
55