1 | <?php |
||
20 | class CallableHandler implements \PEIP\INF\Handler\Handler |
||
21 | { |
||
22 | protected $callable; |
||
23 | |||
24 | /** |
||
25 | * constructor. |
||
26 | * |
||
27 | * @param callable $callable the callable to wrap with the handler |
||
28 | * |
||
29 | * @return |
||
30 | */ |
||
31 | public function __construct($callable) |
||
35 | |||
36 | /** |
||
37 | * Handles a subject by calling the wrapped callable with the subject as argument. |
||
38 | * |
||
39 | * @implements \PEIP\INF\Handler\Handler |
||
40 | * |
||
41 | * @param mixed $subject the subject to handle |
||
42 | * |
||
43 | * @return mixed result of calling the registered callable with given subject |
||
44 | */ |
||
45 | public function handle($subject) |
||
49 | |||
50 | /** |
||
51 | * Allows the handler instance to act as a lambda function. |
||
52 | * Delegates to own 'handle' method. |
||
53 | * |
||
54 | * @param mixed $subject the subject to handle |
||
55 | * |
||
56 | * @return mixed result of calling the registered callable with given subject |
||
57 | * |
||
58 | * @see CallableHandler::handle |
||
59 | */ |
||
60 | public function __invoke($subject) |
||
64 | |||
65 | /** |
||
66 | * Returns the callable wrapped by the handler instance. |
||
67 | * |
||
68 | * @return callable callable wrapped by the handler |
||
69 | */ |
||
70 | public function getCallable() |
||
74 | } |
||
75 |