Skip to content

Commit e0a5473

Browse files
committed
Merge pull request #51 from FriendsOfSymfony/naming
Improve naming (fix #50)
2 parents 58fa3ae + ed626d3 commit e0a5473

16 files changed

+71
-71
lines changed

doc/cache-invalidator.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ an [adapter](http://en.wikipedia.org/wiki/Adapter_pattern):
2525

2626
```php
2727
use FOS\HttpCache\CacheInvalidator;
28-
use FOS\HttpCache\Invalidation;
28+
use FOS\HttpCache\ProxyClient;
2929

30-
$client = new Invalidation\Varnish();
30+
$client = new ProxyClient\Varnish();
3131
// or
32-
$client = new Invalidation\Nginx();
32+
$client = new ProxyClient\Nginx();
3333

3434
$cacheInvalidator = new CacheInvalidator($client);
3535
```

doc/proxy-clients.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ You can use the caching proxy clients either wrapped by the cache invalidator
55
(recommended), or directly for low-level access to invalidation functionality.
66

77
* [Setup](#setup)
8-
* [CacheProxyInterface](#cacheproxyinterface)
8+
* [ProxyClientInterface](#cacheproxyinterface)
99
* [Purge](#purge)
1010
* [Refresh](#refresh)
1111
* [Ban](#ban)
@@ -20,16 +20,16 @@ You should set up at least one caching proxy client:
2020

2121
Then continue here to find out how to use the proxy clients.
2222

23-
CacheProxyInterface
23+
ProxyClientInterface
2424
-------------------
2525

26-
Each client is an implementation of [CacheProxyInterface](../src/Invalidation/CacheProxyInterface.php).
26+
Each client is an implementation of [ProxyClientInterface](../src/ProxyClient/ProxyClientInterface.php).
2727
All other interfaces, `PurgeInterface`, `RefreshInterface` and `BanInterface`
28-
extend this `CacheProxyInterface`. So each client implements at least one of
28+
extend this `ProxyClientInterface`. So each client implements at least one of
2929
the three [invalidation methods](invalidation-introduction.md#invalidation-methods),
3030
depending on the caching proxy’s abilities.
3131

32-
The `CacheProxyInterface` has one method: `flush()`. After collecting
32+
The `ProxyClientInterface` has one method: `flush()`. After collecting
3333
invalidation requests, `flush()` needs to be called to actually send the
3434
requests to the caching proxy. This is on purpose: this way, we can send
3535
all requests together, reducing the performance impact of sending invalidation

doc/varnish-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ that you want to send invalidation requests to. Make sure to include the port
1414
Varnish runs on if it is not port 80.
1515

1616
```php
17-
use FOS\HttpCache\Invalidation\Varnish;
17+
use FOS\HttpCache\ProxyClient\Varnish;
1818

1919
$servers = array('10.0.0.1', '10.0.0.2:6081'); // Port 80 assumed for 10.0.0.1
2020
$varnish = new Varnish($servers);

src/CacheInvalidator.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use FOS\HttpCache\Exception\InvalidArgumentException;
77
use FOS\HttpCache\Exception\ProxyResponseException;
88
use FOS\HttpCache\Exception\ProxyUnreachableException;
9-
use FOS\HttpCache\Exception\UnsupportedInvalidationMethodException;
10-
use FOS\HttpCache\Invalidation\CacheProxyInterface;
11-
use FOS\HttpCache\Invalidation\Method\BanInterface;
12-
use FOS\HttpCache\Invalidation\Method\PurgeInterface;
13-
use FOS\HttpCache\Invalidation\Method\RefreshInterface;
9+
use FOS\HttpCache\Exception\UnsupportedProxyOperationException;
10+
use FOS\HttpCache\ProxyClient\ProxyClientInterface;
11+
use FOS\HttpCache\ProxyClient\Invalidation\BanInterface;
12+
use FOS\HttpCache\ProxyClient\Invalidation\PurgeInterface;
13+
use FOS\HttpCache\ProxyClient\Invalidation\RefreshInterface;
1414
use Symfony\Component\EventDispatcher\EventDispatcher;
1515
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1616
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -38,7 +38,7 @@ class CacheInvalidator
3838
const INVALIDATE = 'invalidate';
3939

4040
/**
41-
* @var CacheProxyInterface
41+
* @var ProxyClientInterface
4242
*/
4343
protected $cache;
4444

@@ -55,9 +55,9 @@ class CacheInvalidator
5555
/**
5656
* Constructor
5757
*
58-
* @param CacheProxyInterface $cache HTTP cache
58+
* @param ProxyClientInterface $cache HTTP cache
5959
*/
60-
public function __construct(CacheProxyInterface $cache)
60+
public function __construct(ProxyClientInterface $cache)
6161
{
6262
$this->cache = $cache;
6363
}
@@ -159,14 +159,14 @@ public function getTagsHeader()
159159
*
160160
* @param string $path Path or URL
161161
*
162-
* @throws UnsupportedInvalidationMethodException
162+
* @throws UnsupportedProxyOperationException
163163
*
164164
* @return $this
165165
*/
166166
public function invalidatePath($path)
167167
{
168168
if (!$this->cache instanceof PurgeInterface) {
169-
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('PURGE');
169+
throw UnsupportedProxyOperationException::cacheDoesNotImplement('PURGE');
170170
}
171171

172172
$this->cache->purge($path);
@@ -182,14 +182,14 @@ public function invalidatePath($path)
182182
*
183183
* @see RefreshInterface::refresh()
184184
*
185-
* @throws UnsupportedInvalidationMethodException
185+
* @throws UnsupportedProxyOperationException
186186
*
187187
* @return $this
188188
*/
189189
public function refreshPath($path, array $headers = array())
190190
{
191191
if (!$this->cache instanceof RefreshInterface) {
192-
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('REFRESH');
192+
throw UnsupportedProxyOperationException::cacheDoesNotImplement('REFRESH');
193193
}
194194

195195
$this->cache->refresh($path, $headers);
@@ -207,14 +207,14 @@ public function refreshPath($path, array $headers = array())
207207
*
208208
* @param array $headers HTTP headers that path must match to be banned.
209209
*
210-
* @throws UnsupportedInvalidationMethodException If HTTP cache does not support BAN requests
210+
* @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
211211
*
212212
* @return $this
213213
*/
214214
public function invalidate(array $headers)
215215
{
216216
if (!$this->cache instanceof BanInterface) {
217-
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('BAN');
217+
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
218218
}
219219

220220
$this->cache->ban($headers);
@@ -240,14 +240,14 @@ public function invalidate(array $headers)
240240
* @param array|string $hosts Regular expression of a host name or list of
241241
* exact host names to limit banning.
242242
*
243-
* @throws UnsupportedInvalidationMethodException If HTTP cache does not support BAN requests
243+
* @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
244244
*
245245
* @return $this
246246
*/
247247
public function invalidateRegex($path, $contentType = null, $hosts = null)
248248
{
249249
if (!$this->cache instanceof BanInterface) {
250-
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('BAN');
250+
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
251251
}
252252

253253
$this->cache->banPath($path, $contentType, $hosts);
@@ -263,14 +263,14 @@ public function invalidateRegex($path, $contentType = null, $hosts = null)
263263
*
264264
* @param array $tags Cache tags
265265
*
266-
* @throws UnsupportedInvalidationMethodException If HTTP cache does not support BAN requests
266+
* @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
267267
*
268268
* @return $this
269269
*/
270270
public function invalidateTags(array $tags)
271271
{
272272
if (!$this->cache instanceof BanInterface) {
273-
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('BAN');
273+
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
274274
}
275275

276276
$headers = array($this->getTagsHeader() => '('.implode('|', $tags).')(,.+)?$');

src/Exception/ExceptionCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/**
66
* A collection of exceptions that might occur during the flush operation of a
7-
* CacheProxyInterface implementation
7+
* ProxyClientInterface implementation
88
*/
99
class ExceptionCollection extends \Exception implements \IteratorAggregate, \Countable, HttpCacheExceptionInterface
1010
{

src/Exception/UnsupportedInvalidationMethodException.php renamed to src/Exception/UnsupportedProxyOperationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* Thrown when the CacheInvalidator is asked for an operation the underlying
77
* cache proxy does not support.
88
*/
9-
class UnsupportedInvalidationMethodException extends \RuntimeException implements HttpCacheExceptionInterface
9+
class UnsupportedProxyOperationException extends \RuntimeException implements HttpCacheExceptionInterface
1010
{
1111
/**
1212
* @param string $method Name of the HTTP method that would be required.
1313
*
14-
* @return UnsupportedInvalidationMethodException
14+
* @return UnsupportedProxyOperationException
1515
*/
1616
public static function cacheDoesNotImplement($method)
1717
{

src/Invalidation/AbstractCacheProxy.php renamed to src/ProxyClient/AbstractProxyClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace FOS\HttpCache\Invalidation;
3+
namespace FOS\HttpCache\ProxyClient;
44

55
use FOS\HttpCache\Exception\ExceptionCollection;
66
use FOS\HttpCache\Exception\InvalidUrlException;
@@ -18,7 +18,7 @@
1818
*
1919
* @author David de Boer <[email protected]>
2020
*/
21-
abstract class AbstractCacheProxy implements CacheProxyInterface
21+
abstract class AbstractProxyClient implements ProxyClientInterface
2222
{
2323
/**
2424
* IP addresses/hostnames of all caching proxy servers

src/Invalidation/Method/BanInterface.php renamed to src/ProxyClient/Invalidation/BanInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace FOS\HttpCache\Invalidation\Method;
3+
namespace FOS\HttpCache\ProxyClient\Invalidation;
44

5-
use FOS\HttpCache\Invalidation\CacheProxyInterface;
5+
use FOS\HttpCache\ProxyClient\ProxyClientInterface;
66

77
/**
88
* An HTTP cache that supports invalidation by banning, that is, removing
99
* objects from the cache that match a regular expression
1010
*/
11-
interface BanInterface extends CacheProxyInterface
11+
interface BanInterface extends ProxyClientInterface
1212
{
1313
const REGEX_MATCH_ALL = '.*';
1414
const CONTENT_TYPE_ALL = self::REGEX_MATCH_ALL;

src/Invalidation/Method/PurgeInterface.php renamed to src/ProxyClient/Invalidation/PurgeInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace FOS\HttpCache\Invalidation\Method;
3+
namespace FOS\HttpCache\ProxyClient\Invalidation;
44

5-
use FOS\HttpCache\Invalidation\CacheProxyInterface;
5+
use FOS\HttpCache\ProxyClient\ProxyClientInterface;
66

77
/**
88
* An HTTP cache that supports invalidation by purging, that is, removing one
@@ -11,7 +11,7 @@
1111
* Implementations should be configurable with a default host to be able to
1212
* handle purge calls that do not contain a full URL but only a path.
1313
*/
14-
interface PurgeInterface extends CacheProxyInterface
14+
interface PurgeInterface extends ProxyClientInterface
1515
{
1616
/**
1717
* Purge a URL

src/Invalidation/Method/RefreshInterface.php renamed to src/ProxyClient/Invalidation/RefreshInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace FOS\HttpCache\Invalidation\Method;
3+
namespace FOS\HttpCache\ProxyClient\Invalidation;
44

5-
use FOS\HttpCache\Invalidation\CacheProxyInterface;
5+
use FOS\HttpCache\ProxyClient\ProxyClientInterface;
66

77
/**
88
* An HTTP cache that supports invalidation by refresh requests that force a
@@ -11,7 +11,7 @@
1111
* Implementations should be configurable with a default host to be able to
1212
* handle refresh calls that do not contain a full URL but only a path.
1313
*/
14-
interface RefreshInterface extends CacheProxyInterface
14+
interface RefreshInterface extends ProxyClientInterface
1515
{
1616
/**
1717
* Refresh a URL.

0 commit comments

Comments
 (0)