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.

SplNamespaceInfo::getParent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Spl\Info;
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * Class SplNamespaceInfo
20
 *
21
 * @package O2System\Spl\Info
22
 */
23
class SplNamespaceInfo
24
{
25
    /**
26
     * Namespace Name
27
     *
28
     * @var string
29
     */
30
    public $name;
31
32
    /**
33
     * Namespace Paths
34
     *
35
     * @var array
36
     */
37
    public $paths = [];
38
39
    /**
40
     * SplNamespaceInfo::__construct
41
     *
42
     * @param mixed             $namespace
43
     * @param null|string|array $path
44
     */
45
    public function __construct($namespace, $path = null)
46
    {
47
        if (is_object($namespace)) {
48
            $className = get_class($namespace);
49
            $namespace = pathinfo($className, PATHINFO_DIRNAME);
50
51
            $reflection = new \ReflectionClass($className);
52
53
            $path = pathinfo($reflection->getFileName(), PATHINFO_DIRNAME);
54
        }
55
56
        $this->name = $namespace;
57
58
        if (isset($path)) {
59
            if (is_string($path)) {
60
                $this->paths[] = new SplDirectoryInfo($path);
61
            } elseif (is_array($path)) {
62
                foreach ($path as $directory) {
63
                    $this->paths[] = new SplDirectoryInfo($directory);
64
                }
65
            }
66
        }
67
    }
68
69
    // ------------------------------------------------------------------------
70
71
    /**
72
     * SplNamespaceInfo::__call
73
     *
74
     * @param string $method The method name being called
75
     * @param array  $args   The enumerated array containing the parameters passed to the method call
76
     *
77
     * @return mixed|null
78
     */
79
    public function __call($method, array $args = [])
80
    {
81
        if (method_exists($this, $method)) {
82
            return call_user_func_array([&$this, $method], $args);
83
        } elseif (method_exists($this->directoryInfo, $method)) {
0 ignored issues
show
Bug Best Practice introduced by
The property directoryInfo does not exist on O2System\Spl\Info\SplNamespaceInfo. Did you maybe forget to declare it?
Loading history...
84
            return call_user_func_array([&$this->directoryInfo, $method], $args);
85
        }
86
87
        return null;
88
    }
89
90
    // ------------------------------------------------------------------------
91
92
    /**
93
     * SplNamespaceInfo::getParent
94
     *
95
     * Gets the parent namespace.
96
     *
97
     * @return string
98
     */
99
    public function getParent()
100
    {
101
        return str_replace(DIRECTORY_SEPARATOR, '\\', pathinfo($this->name, PATHINFO_DIRNAME)) . '\\';
102
    }
103
}