1 | <?php |
||
10 | abstract class AbstractFactory |
||
11 | { |
||
12 | /** |
||
13 | * Class is a singleton |
||
14 | */ |
||
15 | private function __construct() {} |
||
16 | |||
17 | protected static $factoryMaps = []; |
||
18 | |||
19 | /** |
||
20 | * Returns true if this factory provides the service of the given name. |
||
21 | * |
||
22 | * @param string $name |
||
23 | * @return bool |
||
24 | */ |
||
25 | public static function provides(string $name): bool |
||
31 | |||
32 | /** |
||
33 | * Returns array of all service names that this factory provides. |
||
34 | * |
||
35 | * @return array |
||
36 | */ |
||
37 | public static function getProvidedServiceNames(): array |
||
43 | |||
44 | /** |
||
45 | * Creates and returns the service under the given name. |
||
46 | * |
||
47 | * @param string $name |
||
48 | * @param array ...$params Parameters passed to the actual factory. |
||
49 | * @return mixed |
||
50 | * @throws Exception |
||
51 | */ |
||
52 | public static function create(string $name, ...$params) |
||
93 | |||
94 | /** |
||
95 | * Registers a n |
||
96 | * |
||
97 | * @param string $name |
||
98 | * @param string|\Closure|object $factory |
||
99 | * @param bool $allowOverride |
||
100 | */ |
||
101 | public static function registerFactory(string $name, $factory, bool $allowOverride = false): void |
||
138 | |||
139 | /** |
||
140 | * Can return an instance/class name that the factories have to return an instance of. |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | protected static function requiresInstanceOf(): string |
||
148 | |||
149 | protected static function loadFactoryMap(): void |
||
156 | |||
157 | /** |
||
158 | * Has to return map of names to factory closures. |
||
159 | * |
||
160 | * @return array |
||
161 | */ |
||
162 | abstract protected static function getFactoryMap(): array; |
||
163 | } |
||
164 |
This check looks for the bodies of
elseif
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
elseif
bodies can be removed. If you have an empty elseif but statements in theelse
branch, consider inverting the condition.