| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | public function generateBanCommand(array $hosts): string |
||
| 41 | { |
||
| 42 | if (! is_array($hosts)) { |
||
| 43 | $hosts = [$hosts]; |
||
| 44 | } |
||
| 45 | |||
| 46 | $hostsRegex = collect($hosts) |
||
| 47 | ->map(function (string $host) { |
||
| 48 | return "(^{$host}$)"; |
||
| 49 | }) |
||
| 50 | ->implode('|'); |
||
| 51 | |||
| 52 | $config = config('laravel-varnish'); |
||
| 53 | |||
| 54 | return "sudo varnishadm -S {$config['secret']} -T 127.0.0.1:{$config['administrative_port']} 'ban req.http.host ~ {$hostsRegex}'"; |
||
| 55 | } |
||
| 56 | |||
| 70 |