Total Complexity | 11 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 95.65% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class InterfaceLocator extends AbstractLocator implements InterfacesInterface |
||
13 | { |
||
14 | public const INJECTOR = InterfaceLocatorInjector::class; |
||
15 | |||
16 | 5 | public function getInterfaces(string|null $target = null): array |
|
17 | { |
||
18 | 5 | if (!empty($target)) { |
|
19 | 2 | $target = new \ReflectionClass($target); |
|
20 | } |
||
21 | |||
22 | 5 | $result = []; |
|
23 | 5 | foreach ($this->availableInterfaces() as $interface) { |
|
24 | try { |
||
25 | 5 | $reflection = $this->classReflection($interface); |
|
26 | 4 | } catch (LocatorException $e) { |
|
27 | 4 | if ($this->debug) { |
|
28 | throw $e; |
||
29 | } |
||
30 | |||
31 | //Ignoring |
||
32 | 4 | continue; |
|
33 | } |
||
34 | |||
35 | 5 | if (!$this->isTargeted($reflection, $target)) { |
|
36 | 2 | continue; |
|
37 | } |
||
38 | |||
39 | 5 | $result[$reflection->getName()] = $reflection; |
|
40 | } |
||
41 | |||
42 | 5 | return $result; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * Classes available in finder scope. |
||
47 | * |
||
48 | * @return class-string[] |
||
|
|||
49 | */ |
||
50 | 5 | protected function availableInterfaces(): array |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * Check if given class targeted by locator. |
||
63 | * |
||
64 | * @param \ReflectionClass|null $target |
||
65 | */ |
||
66 | 5 | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target = null): bool |
|
73 | } |
||
74 | } |
||
75 |