1 | <?php |
||
23 | class Pipeline implements MiddlewarePipelineInterface |
||
24 | { |
||
25 | /** @var ConfigInterface */ |
||
26 | private $config; |
||
27 | /** @var array */ |
||
28 | private $priorityList; |
||
29 | /** @var array */ |
||
30 | private $pipelineList; |
||
31 | /** @var array */ |
||
32 | private $keyMiddlewareList; |
||
33 | /** @var int */ |
||
34 | private $index; |
||
35 | |||
36 | /** |
||
37 | * Pipeline constructor. |
||
38 | * |
||
39 | * @param ConfigInterface $pipelineConfig |
||
40 | */ |
||
41 | 9 | public function __construct(ConfigInterface $pipelineConfig) |
|
63 | |||
64 | /** |
||
65 | * Add middleware definitions to the pipeline. |
||
66 | */ |
||
67 | 9 | private function buildPipeline() |
|
79 | |||
80 | /** |
||
81 | * Checks the given class against Middleware Criterias. |
||
82 | * |
||
83 | * @param $middleWareClass |
||
84 | * |
||
85 | * @throws RuntimeException |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | 9 | private function checkMiddleware($middleWareClass) |
|
103 | |||
104 | /** |
||
105 | * Adds a new middleware to the pipeline queue. |
||
106 | * |
||
107 | * @param string $middleWareClass |
||
108 | * @param int $priority |
||
109 | * |
||
110 | * @throws RuntimeException |
||
111 | * |
||
112 | * @return $this |
||
113 | */ |
||
114 | 9 | public function queueMiddleware($middleWareClass, $priority = 50) |
|
138 | |||
139 | /** |
||
140 | * Sorts the pipeline elements according to the priority. |
||
141 | */ |
||
142 | 6 | private function sortPipeline() |
|
151 | |||
152 | /** |
||
153 | * Starts the pipeline. |
||
154 | * |
||
155 | * @return null|string |
||
156 | */ |
||
157 | 6 | public function start() |
|
164 | |||
165 | /** |
||
166 | * Gets next element from the pipeline. |
||
167 | * |
||
168 | * @return null|string |
||
169 | */ |
||
170 | 7 | public function next() |
|
178 | |||
179 | /** |
||
180 | * Gets the full pipeline list. |
||
181 | * |
||
182 | * @return array |
||
183 | */ |
||
184 | 1 | public function getPipelineList() |
|
188 | } |
||
189 |