1 | <?php |
||
19 | class Tube implements TubeAwareInterface |
||
20 | { |
||
21 | /** @var TubeStatus */ |
||
22 | protected $tubeStatus; |
||
23 | |||
24 | /** @var Server */ |
||
25 | protected $server; |
||
26 | |||
27 | /** @var JobFactory */ |
||
28 | protected $jobFactory; |
||
29 | |||
30 | /** @var CommandFactory */ |
||
31 | protected $commandFactory; |
||
32 | |||
33 | /** |
||
34 | * @param string $tubeName |
||
35 | * @param Server $server |
||
36 | * @param JobFactory|null $jobFactory |
||
37 | */ |
||
38 | 16 | public function __construct($tubeName, Server $server, JobFactory $jobFactory = null) |
|
47 | |||
48 | /** |
||
49 | * @inheritDoc |
||
50 | */ |
||
51 | 12 | public function getTubeStatus() |
|
55 | |||
56 | /** |
||
57 | * @inheritDoc |
||
58 | */ |
||
59 | 2 | public function transformTubeStatusTo(TubeStatus $tubeStatus, $mode = TubeStatus::TRANSFORM_USE) |
|
63 | |||
64 | /** |
||
65 | * @return Job|null If no job in the ready state was found, null is returned |
||
66 | */ |
||
67 | 3 | public function peekReady() |
|
71 | |||
72 | /** |
||
73 | * @return Job|null If no job in the delayed state was found, null is returned |
||
74 | */ |
||
75 | 1 | public function peekDelayed() |
|
79 | |||
80 | /** |
||
81 | * @return Job|null If no job in the buried state was found, null is returned |
||
82 | */ |
||
83 | 1 | public function peekBuried() |
|
87 | |||
88 | /** |
||
89 | * @param CommandInterface $command |
||
90 | * @return Job|null |
||
91 | * @throws Exception\InvalidArgumentException |
||
92 | */ |
||
93 | 5 | protected function peek(CommandInterface $command) |
|
102 | |||
103 | 9 | protected function sync() |
|
107 | |||
108 | /** |
||
109 | * @param int $howMany |
||
110 | * @return int |
||
111 | * @throws InvalidArgumentException |
||
112 | */ |
||
113 | 3 | public function kick($howMany = Beanie::DEFAULT_MAX_TO_KICK) |
|
120 | |||
121 | /** |
||
122 | * @return array |
||
123 | * @throws NotFoundException If this tube has no data, i.e. it does not exist. |
||
124 | */ |
||
125 | 1 | public function stats() |
|
133 | |||
134 | /** |
||
135 | * @return string |
||
136 | */ |
||
137 | 1 | public function getName() |
|
141 | |||
142 | /** |
||
143 | * @param int $howLong |
||
144 | * @return bool |
||
145 | * @throws InvalidArgumentException |
||
146 | * @throws NotFoundException If this tube does not exist, it cannot be paused. |
||
147 | */ |
||
148 | 3 | public function pause($howLong) |
|
157 | |||
158 | 6 | private function checkConstraints($actual, $minimum, $message) |
|
164 | |||
165 | /** |
||
166 | * @param string $command |
||
167 | * @param array $arguments |
||
168 | * @return Response |
||
169 | */ |
||
170 | 4 | private function executeCommand($command, $arguments = []) |
|
176 | } |
||
177 |