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
Pull Request — master (#837)
by E
07:31 queued 05:03
created

ThemeConfigPathResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the ApiGen (http://apigen.org)
5
 *
6
 * For the full copyright and license information, please view
7
 * the file LICENSE that was distributed with this source code.
8
 */
9
10
namespace ApiGen\Theme;
11
12
use ApiGen\Configuration\Exceptions\ConfigurationException;
13
use ApiGen\Utils\FileSystem;
14
15
class ThemeConfigPathResolver
16
{
17
18
    /**
19
     * @var string
20
     */
21
    private $rootDir;
22
23
24
    /**
25
     * @param string $rootDir
26
     */
27
    public function __construct($rootDir)
28
    {
29
        $this->rootDir = $rootDir;
30
    }
31
32
33
    /**
34
     * @param string $path
35
     * @return string
36
     */
37
    public function resolve($path)
38
    {
39
        $allowedPaths = [
40
            $this->rootDir,
41
            $this->rootDir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'
42
        ];
43
44
        foreach ($allowedPaths as $allowedPath) {
45
            $absolutePath = $allowedPath . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
46
            if (file_exists($absolutePath)) {
47
                return $absolutePath;
48
            }
49
        }
50
51
        throw new ConfigurationException(sprintf('Config "%s" was not found.', $path));
52
    }
53
}
54