1 | <?php |
||
13 | class YamlPipelineRepository implements PipelineRepositoryInterface |
||
14 | { |
||
15 | /** |
||
16 | * @author Andrea Marco Sartori |
||
17 | * |
||
18 | * @var array $pipelines Pipelines list. |
||
19 | */ |
||
20 | protected $pipelines; |
||
21 | |||
22 | /** |
||
23 | * @author Andrea Marco Sartori |
||
24 | * |
||
25 | * @var Cerbero\Workflow\Wrappers\YamlParserInterface $parser YAML parser. |
||
26 | */ |
||
27 | protected $parser; |
||
28 | |||
29 | /** |
||
30 | * @author Andrea Marco Sartori |
||
31 | * |
||
32 | * @var Illuminate\Filesystem\Filesystem $files Filesystem. |
||
33 | */ |
||
34 | protected $files; |
||
35 | |||
36 | /** |
||
37 | * @author Andrea Marco Sartori |
||
38 | * |
||
39 | * @var string $path The workflows path. |
||
40 | */ |
||
41 | protected $path; |
||
42 | |||
43 | /** |
||
44 | * Set the dependencies. |
||
45 | * |
||
46 | * @author Andrea Marco Sartori |
||
47 | * |
||
48 | * @param Cerbero\Workflow\Wrappers\YamlParserInterface $parser |
||
49 | * @param Illuminate\Filesystem\Filesystem $files |
||
50 | * @param string $path |
||
51 | * |
||
52 | * @return void |
||
|
|||
53 | */ |
||
54 | 33 | public function __construct(YamlParserInterface $parser, Filesystem $files, $path) |
|
64 | |||
65 | /** |
||
66 | * Parse the YAML file. |
||
67 | * |
||
68 | * @author Andrea Marco Sartori |
||
69 | * |
||
70 | * @return array |
||
71 | */ |
||
72 | 33 | private function parseYaml() |
|
78 | |||
79 | /** |
||
80 | * Retrieve the source of the pipelines. |
||
81 | * |
||
82 | * @author Andrea Marco Sartori |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 33 | public function getSource() |
|
92 | |||
93 | /** |
||
94 | * Determine whether a given pipeline exists. |
||
95 | * |
||
96 | * @author Andrea Marco Sartori |
||
97 | * |
||
98 | * @param string $pipeline |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | 6 | public function exists($pipeline) |
|
108 | |||
109 | /** |
||
110 | * Normalize the name of the given pipeline. |
||
111 | * |
||
112 | * @author Andrea Marco Sartori |
||
113 | * |
||
114 | * @param string $pipeline |
||
115 | * |
||
116 | * @return void |
||
117 | */ |
||
118 | 9 | protected function normalizePipeline(&$pipeline) |
|
122 | |||
123 | /** |
||
124 | * Retrieve the pipes of a given pipeline. |
||
125 | * |
||
126 | * @author Andrea Marco Sartori |
||
127 | * |
||
128 | * @param string $pipeline |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | 3 | public function getPipesByPipeline($pipeline) |
|
138 | |||
139 | /** |
||
140 | * Create the pipelines storage. |
||
141 | * |
||
142 | * @author Andrea Marco Sartori |
||
143 | * |
||
144 | * @return void |
||
145 | */ |
||
146 | 3 | public function settle() |
|
152 | |||
153 | /** |
||
154 | * Store the given pipeline and its pipes. |
||
155 | * |
||
156 | * @author Andrea Marco Sartori |
||
157 | * |
||
158 | * @param string $pipeline |
||
159 | * @param array $pipes |
||
160 | * |
||
161 | * @return void |
||
162 | */ |
||
163 | 3 | public function store($pipeline, array $pipes) |
|
171 | |||
172 | /** |
||
173 | * Update the given pipeline and its pipes. |
||
174 | * |
||
175 | * @author Andrea Marco Sartori |
||
176 | * |
||
177 | * @param string $pipeline |
||
178 | * @param array $attachments |
||
179 | * @param array $detachments |
||
180 | * |
||
181 | * @return void |
||
182 | */ |
||
183 | 9 | public function update($pipeline, array $attachments, array $detachments) |
|
191 | |||
192 | /** |
||
193 | * Detach pipes from a given pipeline. |
||
194 | * |
||
195 | * @author Andrea Marco Sartori |
||
196 | * |
||
197 | * @param array $pipeline |
||
198 | * @param array $pipes |
||
199 | * |
||
200 | * @return void |
||
201 | */ |
||
202 | 9 | protected function detach(array &$pipeline, array $pipes) |
|
206 | |||
207 | /** |
||
208 | * Attach pipes to a given pipeline. |
||
209 | * |
||
210 | * @author Andrea Marco Sartori |
||
211 | * |
||
212 | * @param array $pipeline |
||
213 | * @param array $pipes |
||
214 | * |
||
215 | * @return void |
||
216 | */ |
||
217 | 9 | protected function attach(array &$pipeline, array $pipes) |
|
221 | |||
222 | /** |
||
223 | * Refresh the pipelines source. |
||
224 | * |
||
225 | * @author Andrea Marco Sartori |
||
226 | * |
||
227 | * @return void |
||
228 | */ |
||
229 | 12 | protected function refreshPipelines() |
|
235 | |||
236 | /** |
||
237 | * Destroy a given pipeline. |
||
238 | * |
||
239 | * @author Andrea Marco Sartori |
||
240 | * |
||
241 | * @param string $pipeline |
||
242 | * |
||
243 | * @return void |
||
244 | */ |
||
245 | 3 | public function destroy($pipeline) |
|
251 | } |
||
252 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.