| 1 | <?php |
||
| 7 | abstract class AbstractServiceCaller |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * The container implementation. |
||
| 11 | * |
||
| 12 | * @var \Illuminate\Contracts\Container\Container |
||
| 13 | */ |
||
| 14 | protected $container; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The handler method to be called. |
||
| 18 | * |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | public static $handlerMethod; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Create a new service caller instance. |
||
| 25 | * |
||
| 26 | * @param \Illuminate\Contracts\Container\Container $container |
||
| 27 | */ |
||
| 28 | public function __construct(Container $container) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Call a service through its appropriate handler. |
||
| 35 | * |
||
| 36 | * @param string $service |
||
| 37 | * @param mixed ...$params |
||
| 38 | * |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | abstract public function call($service, ...$params); |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Determine if the service handler method exists. |
||
| 45 | * |
||
| 46 | * @param mixed $service |
||
| 47 | * |
||
| 48 | * @return bool |
||
| 49 | */ |
||
| 50 | public function hasHandler($service) |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Set the handler method name for services. |
||
| 57 | * |
||
| 58 | * @param string $method |
||
| 59 | */ |
||
| 60 | public static function setHandlerMethod(string $method = 'run') |
||
| 64 | } |
||
| 65 |