Total Complexity | 7 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Changes | 5 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class Varnish |
||
9 | { |
||
10 | /** |
||
11 | * @param string|array $host |
||
12 | * @param string $url |
||
13 | * |
||
14 | * @return \Symfony\Component\Process\Process |
||
15 | */ |
||
16 | public function flush($host = null, string $url = null): Process |
||
17 | { |
||
18 | $host = $this->getHosts($host); |
||
19 | |||
20 | $command = $this->generateBanCommand($host, $url); |
||
21 | |||
22 | return $this->executeCommand($command); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param array|string $host |
||
27 | * |
||
28 | * @return array |
||
29 | */ |
||
30 | protected function getHosts($host = null): array |
||
31 | { |
||
32 | $host = $host ?? config('varnish.host'); |
||
33 | |||
34 | if (! is_array($host)) { |
||
35 | $host = [$host]; |
||
36 | } |
||
37 | |||
38 | return $host; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param array $hosts |
||
43 | * @param string $url |
||
44 | * @return string |
||
45 | */ |
||
46 | public function generateBanCommand(array $hosts, string $url = null): string |
||
62 | } |
||
63 | |||
64 | protected function executeCommand(string $command): Process |
||
77 |