Passed
Push — master ( 0bd3f5...0b454c )
by Mike
05:30
created

DependencyProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 9
dl 0
loc 63
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 3 1
A __construct() 0 3 1
A set() 0 5 1
A get() 0 3 1
A register() 0 3 1
A getLocator() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Core\Dependency;
6
7
8
use Xervice\Core\Config\ConfigInterface;
9
use Xervice\Core\Dependency\Provider\ProviderInterface;
10
use Xervice\Core\Locator\Locator;
11
12
13
class DependencyProvider extends AbstractDependencyProvider implements DependencyProviderInterface
14
{
15
    /**
16
     * @var \Xervice\Core\Config\ConfigInterface
17
     */
18
    private $config;
19
20
    /**
21
     * DependencyProvider constructor.
22
     *
23
     * @param \Xervice\Core\Config\ConfigInterface $config
24
     */
25 9
    public function __construct(ConfigInterface $config)
26
    {
27 9
        $this->config = $config;
28 9
    }
29
30
31
    /**
32
     * @param string $name
33
     * @param callable $function
34
     *
35
     * @return \Xervice\Core\Dependency\DependencyProviderInterface
36
     */
37 6
    public function set(string $name, callable $function): DependencyProviderInterface
38
    {
39 6
        $this->container[$name] = $function;
40
41 6
        return $this;
42
    }
43
44
    /**
45
     * @param string $name
46
     *
47
     * @return mixed
48
     */
49 6
    public function get(string $name)
50
    {
51 6
        return $this->container[$name]($this);
52
    }
53
54
    /**
55
     * @return \Xervice\Core\Config\ConfigInterface
56
     */
57 1
    public function getConfig(): ConfigInterface
58
    {
59 1
        return $this->config;
60
    }
61
62
    /**
63
     * @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...
64
     */
65 1
    public function getLocator(): Locator
66
    {
67 1
        return Locator::getInstance();
68
    }
69
70
    /**
71
     * @param \Xervice\Core\Dependency\Provider\ProviderInterface $provider
72
     */
73 3
    public function register(ProviderInterface $provider): void
74
    {
75 3
        $provider->handleDependencies($this);
76 3
    }
77
78
79
}