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 ( de1771...791612 )
by Vermeulen
04:28
created

Options::checkPaths()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 24
Code Lines 14

Duplication

Lines 18
Ratio 75 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 18
loc 24
rs 8.5125
cc 5
eloc 14
nc 9
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
     * Search the root and vendor paths if they are not declared.
12
     * 
13
     * @return $this
14
     */
15
    public function searchPaths()
16
    {
17
        //Search root directory if is not declared
18
        if ($this->options['rootDir'] === null) {
19
            $this->options['rootDir'] = $this->searchRootDir();
20
        }
21
22
        //Search the vendor directory if is not declared
23
        if ($this->options['vendorDir'] === null) {
24
            $this->options['vendorDir'] = $this->searchVendorDir();
25
        }
26
        
27
        return $this;
28
    }
29
    
30
    /**
31
     * Check root and vendor path declared or found.
32
     * 
33
     * @return $this
34
     */
35
    public function checkPaths()
36
    {
37 View Code Duplication
        if (empty($this->options['rootDir'])) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
            $this->options['rootDir'] .= '/';
39
        } else {
40
            $rootDirPosLastChar = strlen($this->options['rootDir']) - 1;
41
            
42
            if ($this->options['rootDir'][$rootDirPosLastChar] !== '/') {
43
                $this->options['rootDir'] .= '/';
44
            }
45
        }
46
        
47 View Code Duplication
        if (empty($this->options['vendorDir'])) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
            $this->options['vendorDir'] .= '/';
49
        } else {
50
            $vendorDirPosLastChar = strlen($this->options['vendorDir']) - 1;
51
            
52
            if ($this->options['vendorDir'][$vendorDirPosLastChar] !== '/') {
53
                $this->options['vendorDir'] .= '/';
54
            }
55
        }
56
        
57
        return $this;
58
    }
59
60
    /**
61
     * Find the vendor directory from the path of this file
62
     * (In theory we are into)
63
     * 
64
     * @return string
65
     */
66
    protected function searchVendorDir()
67
    {
68
        if (PHP_VERSION_ID >= 70000) {
69
            return dirname(__FILE__, 5).'/';
70
        }
71
72
        $rootDir = __FILE__;
73
        for ($i = 1; $i <= 5; $i++) {
74
            $rootDir = dirname($rootDir);
75
        }
76
77
        return $rootDir.'/';
78
    }
79
80
    /**
81
     * Find the root directory from the vendor directory
82
     * In theory of the vendor directory is on the root directory.
83
     * If not, the user can define path for vendor and root directory.
84
     * 
85
     * @return string
86
     */
87
    protected function searchRootDir()
88
    {
89
        return dirname($this->searchVendorDir()).'/';
90
    }
91
}
92