| Total Complexity | 8 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 76.47% |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 7 | abstract class BaseFacade |
||
| 8 | { |
||
| 9 | protected static $resolved_instance = []; |
||
| 10 | |||
| 11 | 261 | public static function __callStatic($method, $args) |
|
| 12 | { |
||
| 13 | 261 | if ($instance = static::getFacadeRoot()) { |
|
| 14 | 261 | return $instance->$method(...$args); |
|
| 15 | } |
||
| 16 | |||
| 17 | throw new RuntimeException('A facade root has not been set.'); |
||
| 18 | } |
||
| 19 | |||
| 20 | 261 | public static function getFacadeRoot() |
|
| 21 | { |
||
| 22 | 261 | return static::resolveFacadeInstance(static::getFacadeAccessor()); |
|
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Clear all of the resolved instances. |
||
| 27 | */ |
||
| 28 | 261 | public static function clearResolvedInstances() |
|
| 29 | { |
||
| 30 | 261 | static::$resolved_instance = []; |
|
| 31 | 261 | } |
|
| 32 | |||
| 33 | /** |
||
| 34 | * @return object|string |
||
| 35 | */ |
||
| 36 | protected static function getFacadeAccessor() |
||
| 37 | { |
||
| 38 | throw new RuntimeException('Facade does not implement getFacadeAccessor method.'); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param object|string $facade |
||
| 43 | * |
||
| 44 | * @return object |
||
| 45 | */ |
||
| 46 | 261 | protected static function resolveFacadeInstance($facade): object |
|
| 57 | } |
||
| 58 | } |
||
| 59 |