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.

AbstractComplexityChecker::setThreshold()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Inspector\Analysis\Checker\Complexity;
4
5
use PhpParser\Node;
6
use PhpParser\Node\Stmt\ClassMethod;
7
use Inspector\Misc\ParametersInterface;
8
use Inspector\Analysis\Checker\CheckerInterface;
9
use Inspector\Analysis\Complexity\ComplexityComputer;
10
use Inspector\Analysis\Exception\MethodTooComplexException;
11
use Inspector\Analysis\Complexity\ComplexityComputerAwareInterface;
12
13
abstract class AbstractComplexityChecker implements CheckerInterface, ParametersInterface, ComplexityComputerAwareInterface
14
{
15
16
    /**
17
     * @var ComplexityComputer
18
     */
19
    protected $complexityComputer;
20
21
    /**
22
     * @var int
23
     */
24
    protected $threshold;
25
26
    /**
27
     * @param ComplexityComputer $complexityComputer
28
     * @return $this
29
     */
30
    public function setComplexityComputer(ComplexityComputer $complexityComputer)
31
    {
32
        $this->complexityComputer = $complexityComputer;
33
34
        return $this;
35
    }
36
37
    /**
38
     * Checks to make sure the class method is not that complex
39
     *
40
     * @param Node $node
41
     * @throws MethodTooComplexException
42
     */
43
    public function check(Node $node)
44
    {
45
        if ($node instanceof ClassMethod) {
46
            $complexity = $this->complexityComputer->compute($node);
47
48
            if ($complexity > $this->threshold) {
49
                throw (new MethodTooComplexException)->setNode($node);
50
            }
51
        }
52
    }
53
54
    /**
55
     * Checks if a part of code is complex
56
     *
57
     * @param Node $node
58
     * @return bool
59
     */
60
    protected function isComplex(Node $node)
61
    {
62
        $complexity = $this->complexityComputer->compute($node);
63
64
        return ($complexity > $this->getThreshold());
65
    }
66
67
    /**
68
     * @return int
69
     */
70
    public function getThreshold()
71
    {
72
        return $this->threshold;
73
    }
74
75
    /**
76
     * @param int $threshold
77
     * @return $this
78
     */
79
    public function setThreshold($threshold)
80
    {
81
        $this->threshold = $threshold;
82
83
        return $this;
84
    }
85
86
}
87