Passed
Push — semantic ( 9e9f01 )
by Akihito
02:35
created

BindingInfo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di\Bindings;
6
7
use JsonSerializable;
8
9
/**
10
 * Value object representing a dependency injection binding
11
 */
12
final class BindingInfo implements JsonSerializable
13
{
14
    /** @var string */
15
    public $interface;
16
17
    /** @var string|null */
18
    public $named;
19
20
    /** @var string */
21
    public $type;
22
23
    /** @var mixed */
24
    public $target;
25
26
    /** @var array<string, list<string>>|null */
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<string, list<string>>|null at position 4 could not be parsed: Expected '>' at position 4, but found 'list'.
Loading history...
27
    public $aop;
28
29
    /**
30
     * @param string $interface
31
     * @param string|null $named
32
     * @param string $type
33
     * @param mixed $target
34
     * @param array<string, list<string>>|null $aop
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<string, list<string>>|null at position 4 could not be parsed: Expected '>' at position 4, but found 'list'.
Loading history...
35
     */
36
    public function __construct(
37
        string $interface,
38
        ?string $named,
39
        string $type,
40
        $target,
41
        ?array $aop = null
42
    ) {
43
        $this->interface = $interface;
44
        $this->named = $named;
45
        $this->type = $type;
46
        $this->target = $target;
47
        $this->aop = $aop;
48
    }
49
50
    /**
51
     * @return array<string, mixed>
52
     */
53
    public function jsonSerialize(): array
54
    {
55
        $data = [
56
            'interface' => $this->interface,
57
            'named' => $this->named,
58
            'type' => $this->type,
59
            'target' => $this->target,
60
        ];
61
62
        if ($this->aop !== null) {
63
            $data['aop'] = $this->aop;
64
        }
65
66
        return $data;
67
    }
68
}