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 ( e0baf9...7f2ebd )
by James
03:10
created

InclusionDirective::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
crap 1
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
use Webmozart\Glob\Iterator\GlobIterator;
15
16
/**
17
 * Describes an inclusion directive instance.
18
 *
19
 * An inclusion directive points to a filesystem pathname.
20
 *
21
 * This pathname can be a file to load at the point of the active config, or
22
 * a list of files in a filesystem directory, using wildcards.
23
 *
24
 * Pathname can be absolute, or relative to a filesystem path defined by another Directive, or
25
 * to the path of the actual configuration file, or to the prefix.
26
 *
27
 * Technically, an inclusion directive is a simple directive that acts as a block directive.
28
 *
29
 * @author James <[email protected]>
30
 */
31
class InclusionDirective extends BlockDirective implements DirectiveInterface
32
{
33
    /** @var string the filesystem path where the web server is installed */
34
    private $prefix;
35
36
    /** @var array file list pointed with that directive */
37
    private $files = [];
38
39
    /**
40
     * Specific constructor for inclusion directives.
41
     *
42
     * @param string $name   the name of the key/context
43
     * @param string $value  the value of the key/context
44
     * @param string $prefix the filesystem path where the web server is installed
45
     */
46 4
    public function __construct($name, $value = '', $prefix = '')
47
    {
48 4
        parent::__construct($name, $value);
49 4
        $this->prefix = $prefix;
50 4
        $this->setFiles();
51 4
    }
52
53
    /**
54
     * Gets the detected files of the directive.
55
     *
56
     * @return array detected files
57
     */
58 3
    public function getFiles()
59
    {
60 3
        return $this->files;
61
    }
62
63
    /**
64
     * Detects and memoizes the included files.
65
     */
66 4
    public function setFiles()
67
    {
68 4
        $this->files = [];
69 4
        $path = $this->getValue();
70
71 4
        if (!preg_match('#^/#', $path)) {
72 2
            $path = $this->prefix.'/'.$path;
73 2
        }
74
75 4
        $iterator = new GlobIterator($path);
76 4
        foreach ($iterator as $path) {
77 3
            $this->files[] = $path;
78 4
        }
79
80 4
        return $this;
81
    }
82
}
83