Completed
Push — master ( b31514...603a9f )
by Changwan
06:16
created

Descriptor   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 5
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 80
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0
wmc 7
lcom 5
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A assign() 0 5 1
A assignMany() 0 5 1
A wire() 0 5 1
A wireMany() 0 5 1
A after() 0 5 1
A factory() 0 5 1
A freeze() 0 5 1
1
<?php
2
namespace Wandu\DI;
3
4
use Wandu\DI\ContainerFluent;
5
6
class Descriptor implements ContainerFluent 
7
{
8
    /** @var array */
9
    public $assigns = [];
10
    
11
    /** @var array */
12
    public $wires = [];
13
    
14
    /** @var callable[] */
15
    public $afterHandlers = [];
16
17
    /** @var bool */
18
    public $factory = false;
19
    
20
    /** @var bool */
21
    public $frozen = false;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 7
    public function assign(string $paramName, $target): ContainerFluent
27
    {
28 7
        $this->assigns[$paramName] = $target;
29 7
        return $this;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 3
    public function assignMany(array $params = []): ContainerFluent
36
    {
37 3
        $this->assigns = $params + $this->assigns;
38 3
        return $this;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 8
    public function wire(string $propertyName, $target): ContainerFluent
45
    {
46 8
        $this->wires[$propertyName] = $target;
47 8
        return $this;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 3
    public function wireMany(array $properties): ContainerFluent
54
    {
55 3
        $this->wires = $properties + $this->wires;
56 3
        return $this;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 4
    public function after(callable $handler): ContainerFluent
63
    {
64 4
        $this->afterHandlers[] = $handler;
65 4
        return $this;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 5
    public function factory(): ContainerFluent
72
    {
73 5
        $this->factory = true;
74 5
        return $this;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 92
    public function freeze(): ContainerFluent
81
    {
82 92
        $this->frozen = true;
83 92
        return $this;
84
    }
85
}
86