Total Complexity | 5 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class Queue { |
||
8 | |||
9 | /** |
||
10 | * @var ConnectionInterface |
||
11 | */ |
||
12 | protected $connection; |
||
13 | |||
14 | /** |
||
15 | * @var Cron |
||
16 | */ |
||
17 | protected $cron; |
||
18 | |||
19 | /** |
||
20 | * Queue constructor. |
||
21 | * |
||
22 | * @param ConnectionInterface $connection |
||
23 | */ |
||
24 | 5 | public function __construct( ConnectionInterface $connection ) { |
|
26 | 5 | } |
|
27 | |||
28 | /** |
||
29 | * Push a job onto the queue; |
||
30 | * |
||
31 | * @param Job $job |
||
32 | * @param int $delay |
||
33 | * |
||
34 | * @return bool|int |
||
35 | */ |
||
36 | 2 | public function push( Job $job, $delay = 0 ) { |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Create a cron worker. |
||
42 | * |
||
43 | * @param int $attempts |
||
44 | * @param int $interval |
||
45 | * |
||
46 | * @return Cron |
||
47 | */ |
||
48 | 1 | public function cron( $attempts = 3, $interval = 5 ) { |
|
49 | 1 | if ( is_null( $this->cron ) ) { |
|
50 | 1 | $this->cron = new Cron( get_class( $this->connection ), $this->worker( $attempts ), $interval ); |
|
51 | 1 | $this->cron->init(); |
|
52 | } |
||
53 | |||
54 | 1 | return $this->cron; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Create a new worker. |
||
59 | * |
||
60 | * @param int $attempts |
||
61 | * |
||
62 | * @return Worker |
||
63 | */ |
||
64 | 2 | public function worker( $attempts ) { |
|
66 | } |
||
67 | } |