1 | <?php |
||
33 | class Runner implements Countable |
||
34 | { |
||
35 | /** |
||
36 | * Resolver |
||
37 | * |
||
38 | * @var callable |
||
39 | * |
||
40 | * @access protected |
||
41 | */ |
||
42 | protected $resolver; |
||
43 | |||
44 | /** |
||
45 | * Task factory |
||
46 | * |
||
47 | * @var callable |
||
48 | * |
||
49 | * @access protected |
||
50 | */ |
||
51 | protected $taskFactory; |
||
52 | |||
53 | /** |
||
54 | * Tasks |
||
55 | * |
||
56 | * @var QueueInterface |
||
57 | * |
||
58 | * @access protected |
||
59 | */ |
||
60 | protected $tasks; |
||
61 | |||
62 | /** |
||
63 | * __construct |
||
64 | * |
||
65 | * @param callable $resolver DESCRIPTION |
||
66 | * @param QueueInterface $queue DESCRIPTION |
||
67 | * |
||
68 | * @access public |
||
69 | */ |
||
70 | 3 | public function __construct( |
|
78 | |||
79 | /** |
||
80 | * Set task factory |
||
81 | * |
||
82 | * @param callable $factory factory to create a task |
||
83 | * |
||
84 | * @return $this |
||
85 | * |
||
86 | * @access public |
||
87 | */ |
||
88 | 3 | public function setTaskFactory(callable $factory) |
|
93 | |||
94 | /** |
||
95 | * Add task |
||
96 | * |
||
97 | * @param mixed $task task to be added |
||
98 | * @param int $priority priority of task |
||
99 | * |
||
100 | * @return $this |
||
101 | * |
||
102 | * @access public |
||
103 | */ |
||
104 | 3 | public function addTask($task, $priority = 1000) |
|
109 | |||
110 | /** |
||
111 | * Add Tasks |
||
112 | * |
||
113 | * @param mixed $tasks tasks to add |
||
114 | * @param int $priority priority of tasks |
||
115 | * |
||
116 | * @return $this |
||
117 | * |
||
118 | * @access public |
||
119 | */ |
||
120 | 1 | public function addTasks($tasks, $priority = 1000) |
|
127 | |||
128 | /** |
||
129 | * Set Tasks |
||
130 | * |
||
131 | * @param mixed $tasks Tasks to set |
||
132 | * @param int $priority tasks priority |
||
133 | * |
||
134 | * @return $this |
||
135 | * |
||
136 | * @access public |
||
137 | */ |
||
138 | 1 | public function setTasks($tasks, $priority = 1000) |
|
143 | |||
144 | /** |
||
145 | * Task |
||
146 | * |
||
147 | * @param mixed $collection collection or collection spec |
||
148 | * @param int $priority priority of task |
||
149 | * |
||
150 | * @return TaskInterface |
||
151 | * |
||
152 | * @access public |
||
153 | */ |
||
154 | 2 | public function task($collection, $priority = 1000) |
|
160 | |||
161 | /** |
||
162 | * Execute all tasks |
||
163 | * |
||
164 | * @return void |
||
165 | * |
||
166 | * @access public |
||
167 | */ |
||
168 | 2 | public function __invoke() |
|
175 | |||
176 | /** |
||
177 | * Count |
||
178 | * |
||
179 | * @return int |
||
180 | * |
||
181 | * @access public |
||
182 | */ |
||
183 | 2 | public function count() |
|
187 | |||
188 | /** |
||
189 | * Run task |
||
190 | * |
||
191 | * @param TaskInterface $task task to run |
||
192 | * |
||
193 | * @return void |
||
194 | * |
||
195 | * @access protected |
||
196 | */ |
||
197 | 2 | protected function runTask(TaskInterface $task) |
|
209 | |||
210 | /** |
||
211 | * Run item tasks |
||
212 | * |
||
213 | * @param mixed $items items on which to execute tasks |
||
214 | * @param mixed $tasks tasks to execute |
||
215 | * |
||
216 | * @return void |
||
217 | * |
||
218 | * @access protected |
||
219 | */ |
||
220 | 2 | protected function runItemTasks($items, $tasks) |
|
229 | |||
230 | /** |
||
231 | * Run collection tasks |
||
232 | * |
||
233 | * @param mixed $items collection on which to run tasks |
||
234 | * @param mixed $tasks tasks to run |
||
235 | * |
||
236 | * @return void |
||
237 | * |
||
238 | * @access protected |
||
239 | */ |
||
240 | 2 | protected function runCollectionTasks($items, $tasks) |
|
247 | |||
248 | /** |
||
249 | * New task |
||
250 | * |
||
251 | * @param mixed $collection collection or collection spec |
||
252 | * |
||
253 | * @return Task |
||
254 | * |
||
255 | * @access protected |
||
256 | */ |
||
257 | 2 | protected function newTask($collection) |
|
265 | |||
266 | /** |
||
267 | * Resolve |
||
268 | * |
||
269 | * @param mixed $spec spec to resolve |
||
270 | * |
||
271 | * @return mixed |
||
272 | * |
||
273 | * @access protected |
||
274 | */ |
||
275 | 2 | protected function resolve($spec) |
|
283 | } |
||
284 |