1 | <?php |
||
9 | class ServiceConfig implements InjectorConfig |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | private $config; |
||
15 | |||
16 | 1 | public function __construct(array $config) |
|
20 | |||
21 | /** |
||
22 | * @param Injector $injector |
||
23 | * @return void |
||
24 | */ |
||
25 | 1 | public function apply(Injector $injector) |
|
54 | |||
55 | /** |
||
56 | * @param array $services |
||
57 | * @return void |
||
58 | */ |
||
59 | 1 | private function applyAliases(Injector $injector, array $services) |
|
65 | |||
66 | /** |
||
67 | * @param array $services |
||
68 | * @return void |
||
69 | */ |
||
70 | 1 | private function applyDelegates(Injector $injector, array $services) |
|
76 | |||
77 | /** |
||
78 | * @param array $delegators |
||
79 | * @return void |
||
80 | */ |
||
81 | 1 | private function applyDelegators(Injector $injector, array $delegators) |
|
88 | |||
89 | /** |
||
90 | * Create a chained prepare() |
||
91 | * |
||
92 | * @param string $service |
||
93 | * @param string[] $delegators |
||
94 | * @return callable |
||
95 | */ |
||
96 | 1 | private function createDelegator($service, array $delegators) |
|
103 | |||
104 | /** |
||
105 | * Create a reducer for a chained prepare() |
||
106 | * |
||
107 | * @param string $service |
||
108 | * @return callable |
||
109 | */ |
||
110 | 1 | private function delegatorReducer(Injector $injector, $service) |
|
121 | |||
122 | /** |
||
123 | * Curry the delegator to only require a container |
||
124 | * |
||
125 | * @param callable $delegator that will be ultimately called |
||
126 | * @param string $service name of service being prepared |
||
127 | * @param callable $callable that returns the instance |
||
128 | * @return callable |
||
129 | */ |
||
130 | 1 | private function curryDelegator(callable $delegator, $service, callable $callable) |
|
136 | |||
137 | /** |
||
138 | * Returns a function that always returns the same value |
||
139 | * |
||
140 | * Also known as a "kestrel" or "k combinator". |
||
141 | * |
||
142 | * @param mixed $x |
||
143 | * @return callable |
||
144 | */ |
||
145 | 1 | private function k($x) |
|
151 | |||
152 | /** |
||
153 | * @param array $values |
||
154 | * @return callable[] |
||
155 | */ |
||
156 | 1 | private function kAll(array $values) |
|
165 | } |
||
166 |