1 | <?php |
||
9 | class GetJob extends BaseCommand implements CommandInterface |
||
10 | { |
||
11 | use StringChecker; |
||
12 | |||
13 | /** |
||
14 | * Tells which class handles the response |
||
15 | * |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $responseHandler = JobsWithQueueResponse::class; |
||
19 | |||
20 | /** |
||
21 | * Available command options |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $options = [ |
||
26 | 'nohang' => false, |
||
27 | 'count' => null, |
||
28 | 'timeout' => null, |
||
29 | 'withcounters' => false |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * Available command arguments, and their mapping to options |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $availableArguments = [ |
||
38 | 'nohang' => 'NOHANG', |
||
39 | 'timeout' => 'TIMEOUT', |
||
40 | 'count' => 'COUNT', |
||
41 | 'withcounters' => 'WITHCOUNTERS' |
||
42 | ]; |
||
43 | |||
44 | /** |
||
45 | * Get command |
||
46 | * |
||
47 | * @return string Command |
||
48 | */ |
||
49 | 18 | public function getCommand() |
|
53 | |||
54 | /** |
||
55 | * Tells if this command blocks while waiting for a response, to avoid |
||
56 | * being affected by connection timeouts. |
||
57 | * |
||
58 | * @return bool If true, this command blocks |
||
59 | */ |
||
60 | 1 | public function isBlocking() |
|
61 | { |
||
62 | 1 | $arguments = $this->getArguments(); |
|
63 | 1 | $options = end($arguments); |
|
64 | 1 | if (is_array($options) && !empty($options['nohang'])) { |
|
65 | return false; |
||
66 | } |
||
67 | 1 | return true; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * Set arguments for the command |
||
72 | * |
||
73 | * The $arguments must contain at least one, possibly more queue names |
||
74 | * to read from. If the last value in the $arguments array is an array, |
||
75 | * it can contain further optional arguments. |
||
76 | * @see $availableArguments |
||
77 | * |
||
78 | * @param array $arguments Arguments |
||
79 | * @throws InvalidOptionException |
||
80 | */ |
||
81 | 20 | public function setArguments(array $arguments) |
|
107 | } |
||
108 |