Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preset: symfony
18 changes: 9 additions & 9 deletions src/CacheInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CacheInvalidator
private $headerLength = 7500;

/**
* Constructor
* Constructor.
*
* @param ProxyClientInterface $cache HTTP cache
*/
Expand Down Expand Up @@ -112,12 +112,12 @@ public function supports($operation)
case self::INVALIDATE:
return $this->cache instanceof BanInterface;
default:
throw new InvalidArgumentException('Unknown operation ' . $operation);
throw new InvalidArgumentException('Unknown operation '.$operation);
}
}

/**
* Set event dispatcher
* Set event dispatcher.
*
* @param EventDispatcherInterface $eventDispatcher
*
Expand All @@ -136,7 +136,7 @@ public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
}

/**
* Get event dispatcher
* Get event dispatcher.
*
* @return EventDispatcherInterface
*/
Expand All @@ -150,7 +150,7 @@ public function getEventDispatcher()
}

/**
* Add subscriber
* Add subscriber.
*
* @param EventSubscriberInterface $subscriber
*
Expand All @@ -166,7 +166,7 @@ public function addSubscriber(EventSubscriberInterface $subscriber)
}

/**
* Set the HTTP header name that will hold cache tags
* Set the HTTP header name that will hold cache tags.
*
* @param string $tagsHeader
*
Expand All @@ -184,7 +184,7 @@ public function setTagsHeader($tagsHeader)
}

/**
* Get the HTTP header name that will hold cache tags
* Get the HTTP header name that will hold cache tags.
*
* @return string
*
Expand All @@ -196,7 +196,7 @@ public function getTagsHeader()
}

/**
* Invalidate a path or URL
* Invalidate a path or URL.
*
* @param string $path Path or URL
* @param array $headers HTTP headers (optional)
Expand All @@ -217,7 +217,7 @@ public function invalidatePath($path, array $headers = array())
}

/**
* Refresh a path or URL
* Refresh a path or URL.
*
* @param string $path Path or URL
* @param array $headers HTTP headers (optional)
Expand Down
4 changes: 2 additions & 2 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Event extends BaseEvent
private $exception;

/**
* Set exception
* Set exception.
*
* @param \Exception $exception
*/
Expand All @@ -28,7 +28,7 @@ public function setException(\Exception $exception)
}

/**
* Get exception
* Get exception.
*
* @return \Exception
*/
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/LogSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function getSubscribedEvents()
{
return array(
Events::PROXY_UNREACHABLE_ERROR => 'onProxyUnreachableError',
Events::PROXY_RESPONSE_ERROR => 'onProxyResponseError'
Events::PROXY_RESPONSE_ERROR => 'onProxyResponseError',
);
}

Expand All @@ -53,7 +53,7 @@ public function onProxyResponseError(Event $event)
private function log($level, \Exception $exception)
{
$context = array(
'exception' => $exception
'exception' => $exception,
);

$this->logger->log($level, $exception->getMessage(), $context);
Expand Down
4 changes: 2 additions & 2 deletions src/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
namespace FOS\HttpCache;

/**
* Events thrown by the FOSHttpCache library
* Events thrown by the FOSHttpCache library.
*/
final class Events
{
const PROXY_UNREACHABLE_ERROR = 'fos_http_cache.error.proxy_unreachable';
const PROXY_RESPONSE_ERROR = 'fos_http_cache.error.response';
const PROXY_RESPONSE_ERROR = 'fos_http_cache.error.response';
}
12 changes: 6 additions & 6 deletions src/Exception/ExceptionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

/**
* A collection of exceptions that might occur during the flush operation of a
* ProxyClientInterface implementation
* ProxyClientInterface implementation.
*/
class ExceptionCollection extends \Exception implements \IteratorAggregate, \Countable, HttpCacheExceptionInterface
class ExceptionCollection extends \Exception implements \IteratorAggregate, \Countable, HttpCacheExceptionInterface
{
private $exceptions = array();

/**
* Add an exception to the collection
* Add an exception to the collection.
*
* @param \Exception $e
*
Expand Down Expand Up @@ -48,11 +48,11 @@ public function getFirst()
return $this->exceptions[0];
}

return null;
return;
}

/**
* Get exception iterator
* Get exception iterator.
*
* @return \ArrayIterator
*/
Expand All @@ -62,7 +62,7 @@ public function getIterator()
}

/**
* Get number of exceptions in collection
* Get number of exceptions in collection.
*
* @return int
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Exception/HttpCacheExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
* Common interface for all exceptions thrown by this library.
*/
interface HttpCacheExceptionInterface
{}
{
}
6 changes: 3 additions & 3 deletions src/Exception/InvalidUrlException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function invalidUrl($url, $reason = null)
$msg .= sprintf('Reason: %s', $reason);
}

return new InvalidUrlException($msg);
return new self($msg);
}

/**
Expand All @@ -40,7 +40,7 @@ public static function invalidUrl($url, $reason = null)
*/
public static function invalidUrlParts($server, array $allowed)
{
return new InvalidUrlException(sprintf(
return new self(sprintf(
'Server "%s" is invalid. Only %s URL parts are allowed.',
$server,
implode(', ', $allowed)
Expand All @@ -56,7 +56,7 @@ public static function invalidUrlParts($server, array $allowed)
*/
public static function invalidUrlScheme($url, $scheme, array $allowed)
{
return new InvalidUrlException(sprintf(
return new self(sprintf(
'Host "%s" with scheme "%s" is invalid. Only schemes "%s" are supported',
$url,
$scheme,
Expand Down
6 changes: 3 additions & 3 deletions src/Exception/MissingHostException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public static function missingHost($path)
{
$msg = sprintf(
'Path "%s" cannot be invalidated without a host. '
. 'Either invalidate full URLs containing hostnames instead of paths '
. 'or configure the caching proxy class with a hostname in the base path.',
.'Either invalidate full URLs containing hostnames instead of paths '
.'or configure the caching proxy class with a hostname in the base path.',
$path
);

return new MissingHostException($msg);
return new self($msg);
}
}
2 changes: 1 addition & 1 deletion src/Exception/ProxyResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public static function proxyResponse($host, $statusCode, $statusMessage, $detail
$message .= ". $details";
}

return new ProxyResponseException($message, $statusCode, $previous);
return new self($message, $statusCode, $previous);
}
}
2 changes: 1 addition & 1 deletion src/Exception/ProxyUnreachableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function proxyUnreachable($host, $message, $details = '', \Excepti
$message .= ". $details";
}

return new ProxyUnreachableException(
return new self(
$message,
0,
$previous
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/TagHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TagHandler
private $tags = array();

/**
* Constructor
* Constructor.
*
* @param CacheInvalidator $invalidator The invalidator instance.
* @param string $tagsHeader Header to use for tags, defaults to X-Cache-Tags.
Expand Down Expand Up @@ -137,7 +137,7 @@ public function invalidateTags(array $tags)
* header length by the largest tag (minus 1 for the implode character)
*/
$tagsize = max(array_map('mb_strlen', $escapedTags));
$elems = floor($this->headerLength / ($tagsize - 1)) ? : 1;
$elems = floor($this->headerLength / ($tagsize - 1)) ?: 1;
} else {
$elems = count($escapedTags);
}
Expand Down
30 changes: 15 additions & 15 deletions src/ProxyClient/AbstractProxyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,35 @@
use Guzzle\Http\Message\RequestInterface;

/**
* Guzzle-based abstract caching proxy client
* Guzzle-based abstract caching proxy client.
*
* @author David de Boer <david@driebit.nl>
*/
abstract class AbstractProxyClient implements ProxyClientInterface
{
/**
* IP addresses/hostnames of all caching proxy servers
* IP addresses/hostnames of all caching proxy servers.
*
* @var array
*/
private $servers;

/**
* HTTP client
* HTTP client.
*
* @var ClientInterface
*/
private $client;

/**
* Request queue
* Request queue.
*
* @var array|RequestInterface[]
*/
private $queue;

/**
* Constructor
* Constructor.
*
* @param array $servers Caching proxy server hostnames or IP addresses,
* including port if not port 80.
Expand All @@ -73,7 +73,7 @@ public function __construct(array $servers, $baseUrl = null, ClientInterface $cl
}

/**
* Set caching proxy servers
* Set caching proxy servers.
*
* @param array $servers Caching proxy proxy server hostnames or IP
* addresses, including port if not port 80.
Expand All @@ -92,7 +92,7 @@ public function setServers(array $servers)

/**
* Set application hostname, optionally including a base URL, for purge and
* refresh requests
* refresh requests.
*
* @param string $url Your application’s base URL or hostname
*/
Expand All @@ -106,7 +106,7 @@ public function setBaseUrl($url)
}

/**
* Get application base URL
* Get application base URL.
*
* @return string Your application base url
*/
Expand All @@ -132,7 +132,7 @@ public function flush()
}

/**
* Add a request to the queue
* Add a request to the queue.
*
* @param string $method HTTP method
* @param string $url URL
Expand Down Expand Up @@ -163,7 +163,7 @@ private function getSignature($method, $url, array $headers)
}

/**
* Create request
* Create request.
*
* @param string $method HTTP method
* @param string $url URL
Expand All @@ -177,7 +177,7 @@ protected function createRequest($method, $url, array $headers = array())
}

/**
* Sends all requests to each caching proxy server
* Sends all requests to each caching proxy server.
*
* Requests are sent in parallel to minimise impact on performance.
*
Expand Down Expand Up @@ -213,7 +213,7 @@ private function sendRequests(array $requests)
}

/**
* Handle request exception
* Handle request exception.
*
* @param GuzzleExceptionCollection $exceptions
*
Expand Down Expand Up @@ -253,7 +253,7 @@ protected function handleException(GuzzleExceptionCollection $exceptions)
}

/**
* Filter a URL
* Filter a URL.
*
* Prefix the URL with "http://" if it has no scheme, then check the URL
* for validity. You can specify what parts of the URL are allowed.
Expand Down Expand Up @@ -296,7 +296,7 @@ protected function filterUrl($url, array $allowedParts = array())
}

/**
* Get default scheme
* Get default scheme.
*
* @return string
*/
Expand All @@ -306,7 +306,7 @@ protected function getDefaultScheme()
}

/**
* Get schemes allowed by caching proxy
* Get schemes allowed by caching proxy.
*
* @return string[] Array of schemes allowed by caching proxy, e.g. 'http'
* or 'https'
Expand Down
Loading