1 | <?php |
||
24 | class Pipeline implements MiddlewarePipelineInterface |
||
25 | { |
||
26 | /** @var array */ |
||
27 | private $priorityList; |
||
28 | /** @var array */ |
||
29 | private $pipelineList; |
||
30 | /** @var array */ |
||
31 | private $keyMiddlewareList; |
||
32 | /** @var int */ |
||
33 | private $index; |
||
34 | |||
35 | /** |
||
36 | * Pipeline constructor. |
||
37 | */ |
||
38 | public function __construct() |
||
57 | |||
58 | /** |
||
59 | * Adds a new middleware to the pipeline queue. |
||
60 | * |
||
61 | * @param string $middleWareClass |
||
62 | * @param int $priority |
||
63 | * |
||
64 | * @throws RuntimeException |
||
65 | * |
||
66 | * @return $this |
||
67 | */ |
||
68 | public function queueMiddleware($middleWareClass, $priority = 50) |
||
93 | |||
94 | /** |
||
95 | * Checks if the pipline is already being processed. |
||
96 | * |
||
97 | * @throws RuntimeException |
||
98 | */ |
||
99 | private function checkPipelineIsStarted() |
||
105 | |||
106 | /** |
||
107 | * Checks if the given middleware is already added to the list. |
||
108 | * |
||
109 | * @param string $middleWareClass |
||
110 | * |
||
111 | * @throws RuntimeException |
||
112 | */ |
||
113 | private function checkDuplicates($middleWareClass) |
||
121 | |||
122 | /** |
||
123 | * Checks if the given class is a middleware. |
||
124 | * |
||
125 | * @param string $middleWareClass |
||
126 | * |
||
127 | * @throws RuntimeException |
||
128 | */ |
||
129 | private function checkClassType($middleWareClass) |
||
139 | |||
140 | /** |
||
141 | * Sorts the pipeline elements according to the priority. |
||
142 | */ |
||
143 | private function sortPipeline() |
||
152 | |||
153 | /** |
||
154 | * Starts the pipeline. |
||
155 | * |
||
156 | * @return null|string |
||
157 | */ |
||
158 | public function start() |
||
165 | |||
166 | /** |
||
167 | * Gets next element from the pipeline. |
||
168 | * |
||
169 | * @return null|string |
||
170 | */ |
||
171 | public function next() |
||
179 | } |
||
180 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.