Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
CRAP | |
100.00% |
1 / 1 |
AbstractProcessor | |
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
16 | |
100.00% |
1 / 1 |
getJobResults | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getJobResult | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
hasJobResults | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCompletedJobs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCompletedJob | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
hasCompletedJobs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFailedJobs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFailedJob | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
hasFailedJobs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFailedExceptions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFailedException | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
hasFailedExceptions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
processNext | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Queue\Processor; |
15 | |
16 | use Pop\Queue\Queue; |
17 | use Pop\Queue\Processor\Jobs\AbstractJob; |
18 | |
19 | /** |
20 | * Abstract process class |
21 | * |
22 | * @category Pop |
23 | * @package Pop\Queue |
24 | * @author Nick Sagona, III <dev@nolainteractive.com> |
25 | * @copyright Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
26 | * @license http://www.popphp.org/license New BSD License |
27 | * @version 1.2.0 |
28 | */ |
29 | abstract class AbstractProcessor implements ProcessorInterface |
30 | { |
31 | |
32 | /** |
33 | * Job results |
34 | * @var array |
35 | */ |
36 | protected $results = []; |
37 | |
38 | /** |
39 | * Completed jobs |
40 | * @var AbstractJob[] |
41 | */ |
42 | protected $completed = []; |
43 | |
44 | /** |
45 | * Failed jobs |
46 | * @var AbstractJob[] |
47 | */ |
48 | protected $failed = []; |
49 | |
50 | /** |
51 | * Failed jobs exceptions |
52 | * @var \Exception[] |
53 | */ |
54 | protected $failedExceptions = []; |
55 | |
56 | /** |
57 | * Get job results |
58 | * |
59 | * @return array |
60 | */ |
61 | public function getJobResults() |
62 | { |
63 | return $this->results; |
64 | } |
65 | |
66 | /** |
67 | * Get job result |
68 | * |
69 | * @param mixed $index |
70 | * @return mixed |
71 | */ |
72 | public function getJobResult($index) |
73 | { |
74 | return (isset($this->results[$index])) ? $this->results[$index] : null; |
75 | } |
76 | |
77 | /** |
78 | * Has job results |
79 | * |
80 | * @return boolean |
81 | */ |
82 | public function hasJobResults() |
83 | { |
84 | return !empty($this->results); |
85 | } |
86 | |
87 | /** |
88 | * Get completed jobs |
89 | * |
90 | * @return array |
91 | */ |
92 | public function getCompletedJobs() |
93 | { |
94 | return $this->completed; |
95 | } |
96 | |
97 | /** |
98 | * Get completed job |
99 | * |
100 | * @param mixed $index |
101 | * @return AbstractJob |
102 | */ |
103 | public function getCompletedJob($index) |
104 | { |
105 | return (isset($this->completed[$index])) ? $this->completed[$index] : null; |
106 | } |
107 | |
108 | /** |
109 | * Has completed jobs |
110 | * |
111 | * @return boolean |
112 | */ |
113 | public function hasCompletedJobs() |
114 | { |
115 | return !empty($this->completed); |
116 | } |
117 | |
118 | /** |
119 | * Get failed jobs |
120 | * |
121 | * @return array |
122 | */ |
123 | public function getFailedJobs() |
124 | { |
125 | return $this->failed; |
126 | } |
127 | |
128 | /** |
129 | * Get failed job |
130 | * |
131 | * @param mixed $index |
132 | * @return AbstractJob |
133 | */ |
134 | public function getFailedJob($index) |
135 | { |
136 | return (isset($this->failed[$index])) ? $this->failed[$index] : null; |
137 | } |
138 | |
139 | /** |
140 | * Has failed jobs |
141 | * |
142 | * @return boolean |
143 | */ |
144 | public function hasFailedJobs() |
145 | { |
146 | return !empty($this->failed); |
147 | } |
148 | |
149 | /** |
150 | * Get failed exceptions |
151 | * |
152 | * @return array |
153 | */ |
154 | public function getFailedExceptions() |
155 | { |
156 | return $this->failedExceptions; |
157 | } |
158 | |
159 | /** |
160 | * Get failed exception |
161 | * |
162 | * @param mixed $index |
163 | * @return \Exception |
164 | */ |
165 | public function getFailedException($index) |
166 | { |
167 | return (isset($this->failedExceptions[$index])) ? $this->failedExceptions[$index] : null; |
168 | } |
169 | |
170 | /** |
171 | * Has failed exceptions |
172 | * |
173 | * @return boolean |
174 | */ |
175 | public function hasFailedExceptions() |
176 | { |
177 | return !empty($this->failedExceptions); |
178 | } |
179 | |
180 | /** |
181 | * Process next job |
182 | * |
183 | * @param Queue $queue |
184 | * @return void |
185 | */ |
186 | abstract public function processNext(Queue $queue = null); |
187 | |
188 | } |