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

Container   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 30
ccs 15
cts 15
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 3 1
A get() 0 3 1
A getLocator() 0 3 1
A withConfig() 0 6 1
A __construct() 0 3 1
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