1 | <?php |
||
12 | class Purge extends Command |
||
13 | { |
||
14 | /** |
||
15 | * The name of the console command. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $name = 'cloudflare:cache:purge'; |
||
20 | |||
21 | /** |
||
22 | * The name and signature of the console command. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $signature = 'cloudflare:cache:purge {zone? : A zone identifier.} |
||
27 | {--file=* : One or more files that should be removed from the cache.} |
||
28 | {--tag=* : One or more tags that should be removed from the cache.} |
||
29 | {--host=* : One or more hosts that should be removed from the cache.}'; |
||
30 | |||
31 | /** |
||
32 | * The name and signature of the console command. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $description = 'Purge files/tags from CloudFlare\'s cache.'; |
||
37 | |||
38 | /** |
||
39 | * CloudFlare API client. |
||
40 | * |
||
41 | * @var \Sebdesign\ArtisanCloudflare\Client |
||
42 | */ |
||
43 | private $client; |
||
44 | |||
45 | /** |
||
46 | * API item identifier tags. |
||
47 | * |
||
48 | * @var \Illuminate\Support\Collection<string, \Symfony\Component\HttpFoundation\ParameterBag> |
||
49 | */ |
||
50 | private $zones; |
||
51 | |||
52 | /** |
||
53 | * Purge constructor. |
||
54 | * |
||
55 | * @param \Sebdesign\ArtisanCloudflare\Client $client |
||
56 | * @param array $zones |
||
57 | */ |
||
58 | public function __construct(Client $client, array $zones) |
||
68 | |||
69 | /** |
||
70 | * Execute the console command. |
||
71 | * |
||
72 | * @return int |
||
73 | */ |
||
74 | public function handle() |
||
92 | |||
93 | /** |
||
94 | * Apply the paremeters for each zone. |
||
95 | * |
||
96 | * Use the config for each zone, unless options are passed in the command. |
||
97 | * |
||
98 | * @param \Illuminate\Support\Collection<string, \Symfony\Component\HttpFoundation\ParameterBag> $zones |
||
99 | * @return \Illuminate\Support\Collection<string, \Symfony\Component\HttpFoundation\ParameterBag> |
||
|
|||
100 | */ |
||
101 | private function applyParameters(Collection $zones) |
||
117 | |||
118 | /** |
||
119 | * Execute the purging operations and return each result. |
||
120 | * |
||
121 | * @param \Illuminate\Support\Collection<string, \Symfony\Component\HttpFoundation\ParameterBag> $zones |
||
122 | * @return \Illuminate\Support\Collection<string, object> |
||
123 | */ |
||
124 | private function purge(Collection $zones) |
||
138 | |||
139 | /** |
||
140 | * Display a table with the results. |
||
141 | * |
||
142 | * @param \Illuminate\Support\Collection<string, \Symfony\Component\HttpFoundation\ParameterBag> $zones |
||
143 | * @param \Illuminate\Support\Collection<string, object> $results |
||
144 | * @return void |
||
145 | */ |
||
146 | private function displayResults(Collection $zones, Collection $results) |
||
200 | |||
201 | /** |
||
202 | * Format an array into a multiline string. |
||
203 | * |
||
204 | * @param array|null $items |
||
205 | * @return string |
||
206 | */ |
||
207 | private function formatItems(array $items = null) |
||
211 | |||
212 | /** |
||
213 | * Format the errors. |
||
214 | * |
||
215 | * @param object[] $errors |
||
216 | * @return string[] |
||
217 | */ |
||
218 | private function formatErrors(array $errors) |
||
228 | |||
229 | /** |
||
230 | * Get the zone identifier from the input argument or the configuration. |
||
231 | * |
||
232 | * @return \Illuminate\Support\Collection<string, \Symfony\Component\HttpFoundation\ParameterBag> |
||
233 | */ |
||
234 | private function getZones() |
||
250 | |||
251 | /** |
||
252 | * Return 1 if all successes are false, otherwise return 0. |
||
253 | * |
||
254 | * @param \Illuminate\Support\Collection $results |
||
255 | * @return int |
||
256 | */ |
||
257 | private function getExitCode(Collection $results) |
||
261 | } |
||
262 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.