1 | <?php |
||
15 | class DelayedOperation implements OperationInterface |
||
16 | { |
||
17 | /** |
||
18 | * Function to check whether operation is pending: |
||
19 | * bool function(SocketInterface $socket, RequestExecutorInterface $executor) |
||
20 | * |
||
21 | * @var callable |
||
22 | */ |
||
23 | private $callable; |
||
24 | |||
25 | /** |
||
26 | * Original operation |
||
27 | * |
||
28 | * @var OperationInterface |
||
29 | */ |
||
30 | private $origin; |
||
31 | |||
32 | /** |
||
33 | * Additional arguments to pass into callback |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | private $arguments; |
||
38 | |||
39 | /** |
||
40 | * DelayedOperation constructor. |
||
41 | * |
||
42 | * @param OperationInterface $origin Original operation which should be delayed |
||
43 | * @param callable $callable Function to check whether operation is pending: |
||
44 | * bool function(SocketInterface $socket, RequestExecutorInterface $executor, ...$arguments) |
||
45 | * @param array $arguments Additional arguments to pass into callback |
||
46 | */ |
||
47 | 3 | public function __construct(OperationInterface $origin, callable $callable, array $arguments = []) |
|
53 | |||
54 | /** {@inheritdoc} */ |
||
55 | 1 | public function getTypes() |
|
56 | { |
||
57 | 1 | return $this->origin->getTypes(); |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * Returns function to invoke |
||
62 | * |
||
63 | * @return callable |
||
64 | */ |
||
65 | 3 | public function getCallable() |
|
69 | |||
70 | /** |
||
71 | * Return original operation to run after delay |
||
72 | * |
||
73 | * @return OperationInterface |
||
74 | */ |
||
75 | 2 | public function getOriginalOperation() |
|
79 | |||
80 | /** |
||
81 | * Return additional arguments to pass into callback |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | 3 | public function getArguments() |
|
89 | } |
||
90 |