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.
Completed
Push — master ( 39d845...dd213f )
by James
02:46
created

BlockDirective::hasDirective()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
crap 3
1
<?php
2
3
/**
4
 * This file is part of WebHelper Parser.
5
 *
6
 * (c) James <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WebHelper\Parser\Directive;
13
14
/**
15
 * Describes a block directive instance or a context.
16
 *
17
 * a BlockDirective is an ordered list of other directives set in a context.
18
 *
19
 * @author James <[email protected]>
20
 */
21
class BlockDirective extends Directive implements DirectiveInterface
22
{
23
    /** @var array orderd list of sub directives */
24
    private $directives = [];
25
26
    /**
27
     * Adds a Directive at the end of the list.
28
     *
29
     * @param DirectiveInterface $directive a directive to add
30
     */
31 6
    public function add(DirectiveInterface $directive)
32
    {
33 6
        $this->directives[] = $directive;
34
35 6
        return $this;
36
    }
37
38
    /**
39
     * Confirms if the directive contains a specified directive.
40
     *
41
     * @param string $name the directive for which to check existence
42
     *
43
     * @return bool true if the sub-directive exists, false otherwise
44
     */
45 1
    public function hasDirective($name)
46
    {
47 1
        $inSubDirective = false;
48
49 1
        foreach ($this->directives as $directive) {
50 1
            if ($directive->getName() == $name) {
51 1
                return true;
52
            }
53
54 1
            $inSubDirective = $this->hasInnerDirective($name, $inSubDirective, $directive);
55 1
        }
56
57 1
        return $inSubDirective;
58
    }
59
60
    /**
61
     * Looks into sub directives to confirm if the actual contains a specified directive.
62
     *
63
     * @param string             $name           the directive for which to check existence
64
     * @param bool               $inSubDirective the actual state
65
     * @param DirectiveInterface $directive      the sub directive to look into
66
     *
67
     * @return bool true if the sub-directive exists, false otherwise
68
     */
69 1
    private function hasInnerDirective($name, $inSubDirective, DirectiveInterface $directive)
70
    {
71 1
        if (!$directive->isSimple()) {
72 1
            $inSubDirective = $inSubDirective || $directive->hasDirective($name);
73 1
        }
74
75 1
        return $inSubDirective;
76
    }
77
78
    /**
79
     * Confirms if the directive is simple.
80
     *
81
     * Block directive can have sub directives
82
     *
83
     * @return bool true if the directive is simple, false otherwise
84
     */
85 1
    public function isSimple()
86
    {
87 1
        return false;
88
    }
89
}
90