Test Failed
Push — master ( cb64a0...36f795 )
by Aleksei
07:38 queued 12s
created

Binder::removeBinding()   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
c 0
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
declare(strict_types=1);
4
5
namespace Spiral\Core\Internal;
6
7
use Psr\Container\ContainerInterface;
8
use Spiral\Core\Internal\Common\DestructorTrait;
9
use Spiral\Core\Internal\Common\Registry;
10
use Spiral\Core\Internal\Config\StateBinder;
11
12
/**
13
 * @internal
14
 */
15
final class Binder extends StateBinder
16
{
17
    use DestructorTrait;
18
19
    private ContainerInterface $container;
20
21
    public function __construct(Registry $constructor)
22
    {
23
        $constructor->set('binder', $this);
24
25
        $this->container = $constructor->get('container', ContainerInterface::class);
26 1004
        parent::__construct($constructor->get('state', State::class));
27
    }
28 1004
29
    public function hasInstance(string $alias): bool
30 1004
    {
31 1004
        if (!$this->container->has($alias)) {
32
            return false;
33
        }
34
        return parent::hasInstance($alias);
35
    }
36
37
    public function destruct(): void
38
    {
39
        unset($this->container);
40
    }
41
}
42