ContainerAutowire::get()   A
last analyzed

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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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