ContainerAutowire   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 2
b 0
f 0
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A register() 0 5 1
A get() 0 3 1
A has() 0 3 1
A decorate() 0 5 1
1
<?php
2
3
/*
4
 *  This file is part of the Micro framework package.
5
 *
6
 *  (c) Stanislau Komar <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace Micro\Component\DependencyInjection\Autowire;
13
14
use Micro\Component\DependencyInjection\Container;
15
16
class ContainerAutowire extends Container
17
{
18
    private AutowireHelperFactoryInterface $autowireHelperFactory;
19
20 19
    public function __construct(private readonly Container $container)
21
    {
22 19
        $this->autowireHelperFactory = new AutowireHelperFactory($this->container);
23
    }
24
25 6
    public function get(string $id): object
26
    {
27 6
        return $this->container->get($id);
28
    }
29
30 1
    public function has(string $id): bool
31
    {
32 1
        return $this->container->has($id);
33
    }
34
35 19
    public function register(string $id, callable $service, bool $force = false): void
36
    {
37 19
        $autowiredCallback = $this->autowireHelperFactory->create()->autowire($service);
38
39 19
        $this->container->register($id, $autowiredCallback, $force);
40
    }
41
42 1
    public function decorate(string $id, callable $service, int $priority = 0): void
43
    {
44 1
        $autowiredCallback = $this->autowireHelperFactory->create()->autowire($service);
45
46 1
        $this->container->decorate($id, $autowiredCallback, $priority);
47
    }
48
}
49