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