Passed
Push — remove-custom-container ( 1805fb...36702b )
by Chema
03:10
created

Container::getLocator()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Container;
6
7
use Gacela\Container\Container as GacelaContainer;
8
use Gacela\Framework\Config\Config;
9
10
/**
11
 * This is a proxy class to simplify the usage of the decoupled Container
12
 */
13
final class Container
14
{
15 10
    private function __construct(
16
        private GacelaContainer $gacelaContainer,
17
    ) {
18 10
    }
19
20 17
    public function get(string $id): mixed
21
    {
22 17
        return $this->gacelaContainer->get($id);
23
    }
24
25 9
    public function set(string $id, mixed $instance): void
26
    {
27 9
        $this->gacelaContainer->set($id, $instance);
28
    }
29
30 10
    public static function withConfig(Config $config): self
31
    {
32 10
        return new self(
33 10
            new GacelaContainer(
34 10
                $config->getFactory()->createGacelaFileConfig()->getMappingInterfaces(),
35 10
                $config->getSetupGacela()->getServicesToExtend(),
36 10
            ),
37 10
        );
38
    }
39
40 1
    public function getLocator(): Locator
41
    {
42 1
        return Locator::getInstance();
43
    }
44
}
45