1 | <?php |
||
13 | class Consumer |
||
14 | { |
||
15 | protected $router; |
||
16 | protected $dispatcher; |
||
17 | protected $shutdown = false; |
||
18 | protected $pause = false; |
||
19 | protected $configured = false; |
||
20 | protected $options = [ |
||
21 | 'max-runtime' => PHP_INT_MAX, |
||
22 | 'max-messages' => null, |
||
23 | 'stop-when-empty' => false, |
||
24 | 'stop-on-error' => false, |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * @param Router $router |
||
29 | * @param EventDispatcherInterface $dispatcher |
||
30 | */ |
||
31 | public function __construct(Router $router, EventDispatcherInterface $dispatcher) |
||
32 | { |
||
33 | $this->router = $router; |
||
34 | $this->dispatcher = $dispatcher; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Starts an infinite loop calling Consumer::tick(); |
||
39 | * |
||
40 | * @param Queue $queue |
||
41 | * @param array $options |
||
42 | */ |
||
43 | public function consume(Queue $queue, array $options = []) |
||
44 | { |
||
45 | declare (ticks = 1); |
||
46 | |||
47 | $this->bind(); |
||
48 | |||
49 | while ($this->tick($queue, $options)) { |
||
50 | // NO op |
||
51 | } |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Returns true do indicate it should be run again or false to indicate |
||
56 | * it should not be run again. |
||
57 | * |
||
58 | * @param Queue $queue |
||
59 | * @param array $options |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | public function tick(Queue $queue, array $options = []) |
||
64 | { |
||
65 | $this->configure($options); |
||
66 | |||
67 | if ($this->shutdown) { |
||
68 | return false; |
||
69 | } |
||
70 | |||
71 | if (microtime(true) > $this->options['max-runtime']) { |
||
72 | return false; |
||
73 | } |
||
74 | |||
75 | if ($this->pause) { |
||
76 | return true; |
||
77 | } |
||
78 | |||
79 | $this->dispatcher->dispatch(BernardEvents::PING, new PingEvent($queue)); |
||
80 | |||
81 | if (!$envelope = $queue->dequeue()) { |
||
82 | return !$this->options['stop-when-empty']; |
||
83 | } |
||
84 | |||
85 | $this->invoke($envelope, $queue); |
||
86 | |||
87 | if (null === $this->options['max-messages']) { |
||
88 | return true; |
||
89 | } |
||
90 | |||
91 | return (boolean) --$this->options['max-messages']; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Mark Consumer as shutdown |
||
96 | */ |
||
97 | public function shutdown() |
||
101 | |||
102 | /** |
||
103 | * Pause consuming |
||
104 | */ |
||
105 | public function pause() |
||
109 | |||
110 | /** |
||
111 | * Resume consuming |
||
112 | */ |
||
113 | public function resume() |
||
117 | |||
118 | /** |
||
119 | * Until there is a real extension point to doing invoked stuff, this can be used |
||
120 | * by wrapping the invoke method. |
||
121 | * |
||
122 | * @param Envelope $envelope |
||
123 | * @param Queue $queue |
||
124 | * |
||
125 | * @throws \Exception |
||
126 | * @throws \Throwable |
||
127 | */ |
||
128 | public function invoke(Envelope $envelope, Queue $queue) |
||
146 | |||
147 | /** |
||
148 | * @param array $options |
||
149 | */ |
||
150 | protected function configure(array $options) |
||
160 | |||
161 | /** |
||
162 | * Setup signal handlers for unix signals. |
||
163 | */ |
||
164 | protected function bind() |
||
172 | |||
173 | /** |
||
174 | * @param \Throwable|\Exception $exception note that the type-hint is missing due to PHP 5.x compat |
||
175 | * |
||
176 | * @param Envelope $envelope |
||
177 | * @param Queue $queue |
||
178 | * |
||
179 | * @throws \Exception |
||
180 | * @throws \Throwable |
||
181 | */ |
||
182 | private function rejectDispatch($exception, Envelope $envelope, Queue $queue) |
||
194 | } |
||
195 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.