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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolve() 0 16 3
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