Total Complexity | 4 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
12 | class ClassLoader extends AbstractLoader |
||
13 | { |
||
14 | /** |
||
15 | * Logic to create entries |
||
16 | * @var callable |
||
17 | */ |
||
18 | protected $apply; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * MappingGenerator constructor. |
||
23 | * |
||
24 | * @param \Iterator $classes |
||
25 | * @param callable $apply Logic to create entries for a class |
||
26 | */ |
||
27 | 8 | public function __construct(\Iterator $classes, callable $apply = null) |
|
32 | 7 | } |
|
33 | |||
34 | |||
35 | /** |
||
36 | * Create new entries |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
40 | 8 | protected function prepareNext(): void |
|
41 | { |
||
42 | 8 | if (!$this->items->valid()) { |
|
43 | 2 | return; |
|
44 | } |
||
45 | |||
46 | 6 | $class = $this->items->current(); |
|
47 | |||
48 | 6 | $entries = i\type_check( |
|
49 | 6 | call_user_func($this->apply, $class), |
|
50 | 6 | 'array', |
|
51 | 6 | new \UnexpectedValueException("Failed to load container entries for '$class': " |
|
52 | 6 | . "Expected array, callback returned %s") |
|
53 | ); |
||
54 | |||
55 | 5 | $this->entries = new \ArrayIterator($entries); |
|
56 | |||
57 | 5 | $this->items->next(); |
|
58 | 5 | } |
|
59 | |||
60 | /** |
||
61 | * Create a container entry for a class using autowiring. |
||
62 | * |
||
63 | * @param string $class |
||
64 | * @return \Closure[] |
||
65 | */ |
||
66 | 1 | protected function createEntry(string $class) |
|
71 | 1 | } |
|
72 | ]; |
||
75 |