1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the LaravelYaml package. |
5
|
|
|
* |
6
|
|
|
* (c) Théo FIDRY <[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 Fidry\LaravelYaml\DependencyInjection\Definition; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author Théo FIDRY <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
final class Service implements ServiceInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $name; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $class; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string[]|Reference[] |
31
|
|
|
*/ |
32
|
|
|
private $arguments; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string[] |
36
|
|
|
*/ |
37
|
|
|
private $autowiringTypes; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var array |
41
|
|
|
*/ |
42
|
|
|
private $tags; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param string $name Name of the service |
46
|
|
|
* @param string $class FQCN of the service |
47
|
|
|
* @param string[]|Reference[] $arguments List of arguments passed for the service instantiation |
48
|
|
|
* @param array|null $autowiringTypes List of autowired classes |
49
|
|
|
* @param array|null $tags |
50
|
|
|
*/ |
51
|
|
|
public function __construct($name, $class, array $arguments = [], array $autowiringTypes = [], array $tags = []) |
52
|
|
|
{ |
53
|
|
|
$this->name = $name; |
54
|
6 |
|
$this->class = $class; |
55
|
|
|
$this->arguments = $arguments; |
56
|
6 |
|
$this->autowiringTypes = $autowiringTypes; |
57
|
6 |
|
$this->tags = $tags; |
58
|
6 |
|
} |
59
|
6 |
|
|
60
|
6 |
|
/** |
61
|
6 |
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function getName() |
64
|
|
|
{ |
65
|
|
|
return $this->name; |
66
|
6 |
|
} |
67
|
|
|
|
68
|
6 |
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function getClass() |
72
|
|
|
{ |
73
|
|
|
return $this->class; |
74
|
6 |
|
} |
75
|
|
|
|
76
|
6 |
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
|
|
public function getArguments() |
80
|
|
|
{ |
81
|
|
|
return $this->arguments; |
82
|
3 |
|
} |
83
|
|
|
|
84
|
3 |
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
|
|
public function getAutowiringTypes() |
88
|
|
|
{ |
89
|
|
|
return $this->autowiringTypes; |
90
|
3 |
|
} |
91
|
|
|
|
92
|
3 |
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
|
|
public function getTags() |
96
|
|
|
{ |
97
|
|
|
return $this->tags; |
98
|
3 |
|
} |
99
|
|
|
|
100
|
3 |
|
/** |
101
|
|
|
* @param ServiceInterface $service |
102
|
|
|
* @param DecorationInterface $decoration |
103
|
|
|
* |
104
|
|
|
* @return $this |
105
|
|
|
*/ |
106
|
|
|
public static function createFromDecoration(ServiceInterface $service, DecorationInterface $decoration) |
107
|
|
|
{ |
108
|
|
|
return new self( |
109
|
|
|
$decoration->getDecoration()[1], |
110
|
|
|
$service->getClass(), |
111
|
|
|
$service->getArguments(), |
112
|
|
|
$service->getAutowiringTypes(), |
113
|
|
|
$service->getTags() |
114
|
|
|
); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|