Test Failed
Push — master ( 2d1715...3b11bb )
by Raffael
03:29
created

Container::make()   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 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Micro\Container
7
 *
8
 * @copyright   Copryright (c) 2018 gyselroth GmbH (https://gyselroth.com)
9
 * @license     MIT https://opensource.org/licenses/MIT
10
 */
11
12
namespace Micro\Container;
13
14
use Psr\Container\ContainerInterface;
15
16
class Container implements ContainerInterface
17
{
18
    /**
19
     * Container.
20
     *
21
     * @var RuntimeContainer
22
     */
23
    protected $container;
24
25
    /**
26
     * Create container.
27
     */
28 54
    public function __construct(array $config = [], ?ContainerInterface $parent = null)
29
    {
30 54
        $this->container = new RuntimeContainer($config, $parent, $this);
31 54
    }
32
33
    /**
34
     * Build an entry of the container by its name.
35
     */
36 3
    public function make(string $name, array $parameters = [])
37
    {
38 3
        return $this->container->get($name, $parameters);
39
    }
40
41
    /**
42
     * Get service.
43
     */
44 49
    public function get($name)
45
    {
46 49
        return $this->container->get($name);
47
    }
48
49
    /**
50
     * Check if service is registered.
51
     */
52 3
    public function has($name): bool
53
    {
54
        try {
55 3
            $this->container->get($name);
56
57 2
            return true;
58 1
        } catch (\Exception $e) {
59 1
            return false;
60
        }
61
    }
62
}
63