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 — 3.0 ( 572920...bfe862 )
by Vermeulen
02:24
created

Options::searchVendorDir()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
3
namespace BFW\Core;
4
5
/**
6
 * Class to define options for BFW Core
7
 */
8
class Options extends \BFW\Options
9
{
10
    /**
11
     * Constructor
12
     * 
13
     * @param array $defaultOption : The default options from BFW Application
14
     * @param array $options : The options declared by user
15
     */
16
    public function __construct($defaultOption, $options)
17
    {
18
        parent::__construct($defaultOption, $options);
19
20
        //Search root directory if is not declared
21
        if ($this->options['rootDir'] === null) {
22
            $this->options['rootDir'] = $this->searchRootDir();
23
        }
24
25
        //Search the vendor directory if is not declared
26
        if ($this->options['vendorDir'] === null) {
27
            $this->options['vendorDir'] = $this->searchVendorDir();
28
        }
29
30
        //Get the length of paths to get the last character position
31
        $rootDirPosLastLetter   = strlen($this->options['rootDir']) - 1;
32
        $vendorDirPosLastLetter = strlen($this->options['vendorDir']) - 1;
33
34
        //If the last caracter is not a "/", add "/" at the end of the path
35
        
36
        if ($this->options['rootDir'][$rootDirPosLastLetter] !== '/') {
37
            $this->options['rootDir'] .= '/';
38
        }
39
40
        if ($this->options['vendorDir'][$vendorDirPosLastLetter] !== '/') {
41
            $this->options['vendorDir'] .= '/';
42
        }
43
    }
44
45
    /**
46
     * Find the vendor directory from the path of this file
47
     * (In theory we are into)
48
     * 
49
     * @return string
50
     */
51
    protected function searchVendorDir()
52
    {
53
        if (PHP_VERSION_ID >= 70000) {
54
            return dirname(__FILE__, 5).'/';
55
        }
56
57
        $rootDir = __FILE__;
58
        for ($i = 1; $i <= 5; $i++) {
59
            $rootDir = dirname($rootDir);
60
        }
61
62
        return $rootDir.'/';
63
    }
64
65
    /**
66
     * Find the root directory from the vendor directory
67
     * In theory of the vendor directory is on the root directory.
68
     * If not, the user can define path for vendor and root directory.
69
     * 
70
     * @return string
71
     */
72
    protected function searchRootDir()
73
    {
74
        return dirname($this->searchVendorDir()).'/';
75
    }
76
}
77