| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 41 | 1 | public function pop() |
|
| 42 | { |
||
| 43 | 1 | $rawJob = $this->client->watchOnly($this->tube)->reserve(0); |
|
| 44 | |||
| 45 | 1 | if (!$rawJob instanceof PheanstalkJob) { |
|
| 46 | 1 | return null; |
|
| 47 | } |
||
| 48 | |||
| 49 | 1 | if (null === $payload = Payload::fromJson($rawJob->getData())) { |
|
| 50 | // can't handle - requeue |
||
| 51 | 1 | $this->client->release($rawJob, 2048); |
|
| 52 | |||
| 53 | 1 | return null; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | $stats = $this->client->statsJob($rawJob); |
|
| 57 | 1 | $attempts = isset($stats['reserves']) ? (int) $stats['reserves'] : 1; |
|
| 58 | |||
| 59 | 1 | return new Job($payload, $attempts, $rawJob); |
|
| 60 | } |
||
| 61 | |||
| 78 |