AbstractDependencyProvider::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomation\Kernel;
13
14
use Psr\Container\ContainerInterface;
15
16
class AbstractDependencyProvider implements ContainerInterface
17
{
18
    protected static array $instances;
19
20
    protected Locator $locator;
21
22
    public function __construct()
23
    {
24
        $this->provideDependencies(new Locator($this));
25
    }
26
27
    //ToDo: Pass Container (DI) with module dynamic resolver of KernelConfig Patterns
28
    public function provideDependencies(Locator $locator): void
0 ignored issues
show
Unused Code introduced by
The parameter $locator is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

28
    public function provideDependencies(/** @scrutinizer ignore-unused */ Locator $locator): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30
    }
31
32
    public function get(string $id)
33
    {
34
        return static::$instances[$id];
35
    }
36
37
    public function has(string $id): bool
38
    {
39
        // TODO: Implement has() method.
40
        return true;
41
    }
42
43
    public function set(string $id, $concrete): void
44
    {
45
        static::$instances[$id] = $concrete;
46
    }
47
}
48