Conditions | 7 |
Paths | 19 |
Total Lines | 32 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 9.8821 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
37 | 2 | public function process() { |
|
38 | 2 | $job = $this->connection->pop(); |
|
39 | |||
40 | 2 | if ( ! $job ) { |
|
41 | 1 | return false; |
|
42 | } |
||
43 | |||
44 | 1 | $exception = null; |
|
45 | |||
46 | try { |
||
47 | 1 | $job->handle(); |
|
48 | } catch ( Exception $exception ) { |
||
49 | $job->release(); |
||
50 | } |
||
51 | |||
52 | 1 | if ( $job->attempts() >= $this->attempts ) { |
|
53 | if ( empty( $exception ) ) { |
||
54 | $exception = new WorkerAttemptsExceededException(); |
||
55 | } |
||
56 | |||
57 | $job->fail(); |
||
58 | } |
||
59 | |||
60 | 1 | if ( $job->failed() ) { |
|
61 | $this->connection->failure( $job, $exception ); |
||
|
|||
62 | 1 | } else if ( $job->released() ) { |
|
63 | $this->connection->release( $job ); |
||
64 | } else { |
||
65 | 1 | $this->connection->delete( $job ); |
|
66 | } |
||
67 | |||
68 | 1 | return true; |
|
69 | } |
||
71 | } |