Completed
Push — master ( b58116...9afd96 )
by Cheren
08:23
created

Path::getInstance()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
/**
3
 * CakeCMS Core
4
 *
5
 * This file is part of the of the simple cms based on CakePHP 3.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package   Core
10
 * @license   MIT
11
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
12
 * @link      https://github.com/CakeCMS/Core".
13
 * @author    Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace Core\Path;
17
18
use JBZoo\Utils\Arr;
19
use JBZoo\Path\Exception;
20
use JBZoo\Path\Path as JBPAth;
21
22
/**
23
 * Class Path
24
 *
25
 * @package Core\Path
26
 */
27
class Path extends JBPAth
28
{
29
30
    /**
31
     * Get path instance.
32
     *
33
     * @param string $key
34
     * @return Path
35
     * @throws Exception
36
     */
37
    public static function getInstance($key = 'default')
38
    {
39
        if ((string) $key = '') {
40
            throw new Exception('Invalid object key');
41
        }
42
43
        if (!Arr::key($key, self::$_objects)) {
44
            self::$_objects[$key] = new self();
45
        }
46
47
        return self::$_objects[$key];
48
    }
49
}
50