| 1 | <?php |
||
| 5 | abstract class AbstractServiceCaller |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * The handler method to be called. |
||
| 9 | * |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | public static $handlerMethod = 'run'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Call a service through its appropriate handler. |
||
| 16 | * |
||
| 17 | * @param string $service |
||
| 18 | * @param mixed ...$params |
||
| 19 | * |
||
| 20 | * @return mixed |
||
| 21 | */ |
||
| 22 | abstract public function call($service, ...$params); |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Determine if the given service has a handler. |
||
| 26 | * |
||
| 27 | * @param mixed $service |
||
| 28 | * |
||
| 29 | * @return bool |
||
| 30 | */ |
||
| 31 | abstract public function hasHandler($service); |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Set the handler method name for services. |
||
| 35 | * |
||
| 36 | * @param string $method |
||
| 37 | */ |
||
| 38 | public static function setHandlerMethod(string $method = 'run') |
||
| 42 | } |
||
| 43 |