Passed
Push — master ( 37f3ab...68213e )
by Mike
02:44
created

Locator::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Core\Locator;
6
7
8
use Xervice\Config\XerviceConfig;
9
use Xervice\Core\CoreConfig;
10
use Xervice\Core\Locator\Proxy\XerviceLocatorProxy;
11
12
class Locator
13
{
14
    /**
15
     * @var \Xervice\Core\Locator\Locator
16
     */
17
    private static $instance;
18
19
    /**
20
     * @var array
21
     */
22
    private $proxies = [];
23
24
    /**
25
     * @var string
26
     */
27
    private $projectNamespace;
28
29
    /**
30
     * @var array
31
     */
32
    private $additionalNamespaces;
33
34
    /**
35
     * Locator constructor.
36
     */
37 1
    public function __construct()
38
    {
39 1
        $this->projectNamespace = $this->getConfig()->get(CoreConfig::PROJECT_LAYER_NAMESPACE, 'App');
40 1
        $this->additionalNamespaces = $this->getConfig()->get(CoreConfig::ADDITIONAL_LAYER_NAMESPACES, []);
41 1
    }
42
43
44
    /**
45
     * @return \Generated\Ide\LocatorAutoComplete|\Xervice\Core\Locator\Locator
0 ignored issues
show
Bug introduced by
The type Generated\Ide\LocatorAutoComplete was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
     */
47 8
    public static function getInstance()
48
    {
49 8
        if (self::$instance === null) {
50 1
            self::$instance = new self();
51
        }
52 8
        return self::$instance;
53
    }
54
55
    /**
56
     * @param $name
57
     * @param $arguments
58
     *
59
     * @return \Xervice\Core\Locator\Proxy\XerviceLocatorProxy
60
     */
61 8
    public function __call($name, $arguments)
62
    {
63 8
        if (!isset($this->proxies[$name])) {
64 4
            $this->proxies[$name] = new XerviceLocatorProxy(
65 4
                $name,
66 4
                $this->projectNamespace,
67 4
                $this->additionalNamespaces
68
            );
69
        }
70
71 8
        return $this->proxies[$name];
72
    }
73
74
    /**
75
     * @return \Xervice\Config\Container\ConfigContainer
76
     */
77 1
    private function getConfig(): \Xervice\Config\Container\ConfigContainer
78
    {
79 1
        return XerviceConfig::getInstance()->getConfig();
80
    }
81
82
}