Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Dec 9, 2016
1 parent 54eba43 commit df436cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
3 changes: 1 addition & 2 deletions config/laravel-varnish.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

return [
'hosts' => [

],
'host' => 'example.com',

'secret' => '/etc/varnish/secret',

Expand Down
24 changes: 10 additions & 14 deletions src/Varnish.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,33 @@
class Varnish
{
/**
* @param string|array $hosts
* @param string|array $host
*
* @return \Symfony\Component\Process\Process
*/
public function flush($hosts = [])
public function flush($host = null)
{
$hosts = $this->getHosts($hosts);
$host = $this->getHosts($host);

$command = $this->generateFlushCommand($hosts);
$command = $this->generateFlushCommand($host);

return $this->executeCommand($command);
}

/**
* @param array|string $hosts
* @param array|string $host
*
* @return array
*/
protected function getHosts($hosts): array
protected function getHosts($host = null): array
{
if (! is_array($hosts)) {
$hosts = [$hosts];
}

if (! count($hosts)) {
$hosts = config('laravel-varnish.hosts');
$host = $host ?? config('laravel-varnish.hosts');

return $hosts;
if (! is_array($host)) {
$host = [$host];
}

return $hosts;
return $host;
}

protected function generateFlushCommand(array $hosts): string
Expand Down

0 comments on commit df436cb

Please sign in to comment.