Skip to content

Commit 15c46f7

Browse files
committed
Fix PSR-4 name issue #4
1 parent f6ba962 commit 15c46f7

File tree

7 files changed

+29
-24
lines changed

7 files changed

+29
-24
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ addons:
1010
- redis-container
1111

1212
php:
13+
- "7.4"
1314
- "7.3"
1415
- "7.2"
1516
- "7.1"
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<?php
2-
/**
3-
* User: jg
4-
* Date: 27/05/17
5-
* Time: 12:21
6-
*/
72

8-
namespace ByJG\Cache;
3+
namespace ByJG\Cache\Exception;
94

10-
11-
class InvalidArgumentException extends \Exception implements \Psr\Cache\InvalidArgumentException
5+
class InvalidArgumentException extends \Exception implements \Psr\Cache\InvalidArgumentException, \Psr\SimpleCache\InvalidArgumentException
126
{
137

148
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
4+
namespace ByJG\Cache\Exception;
5+
6+
class StorageErrorException extends \Exception
7+
{
8+
9+
}

src/Psr16/BaseCacheEngine.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ByJG\Cache\Psr16;
44

55
use ByJG\Cache\CacheAvailabilityInterface;
6-
use ByJG\Cache\InvalidArgumentException;
6+
use ByJG\Cache\Exception\InvalidArgumentException;
77
use Psr\SimpleCache\CacheInterface;
88

99
abstract class BaseCacheEngine implements CacheInterface, CacheAvailabilityInterface
@@ -12,7 +12,6 @@ abstract class BaseCacheEngine implements CacheInterface, CacheAvailabilityInter
1212
* @param $keys
1313
* @param null $default
1414
* @return array|iterable
15-
* @throws \ByJG\Cache\InvalidArgumentException
1615
* @throws \Psr\SimpleCache\InvalidArgumentException
1716
*/
1817
public function getMultiple($keys, $default = null)
@@ -68,4 +67,4 @@ protected function addToNow($ttl)
6867

6968
return null;
7069
}
71-
}
70+
}

src/Psr16/MemcachedEngine.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ByJG\Cache\Psr16;
44

5+
use ByJG\Cache\Exception\StorageErrorException;
56
use Memcached;
67
use Psr\Log\NullLogger;
78

@@ -38,7 +39,7 @@ protected function fixKey($key) {
3839
}
3940

4041
/**
41-
* @throws \Exception
42+
* @throws StorageErrorException
4243
*/
4344
protected function lazyLoadMemCachedServers()
4445
{
@@ -50,7 +51,7 @@ protected function lazyLoadMemCachedServers()
5051

5152
$stats = $this->memCached->getStats();
5253
if (!isset($stats[$server]) || $stats[$server]['pid'] === -1) {
53-
throw new \Exception("Memcached server $server is down");
54+
throw new StorageErrorException("Memcached server $server is down");
5455
}
5556
}
5657
}
@@ -60,7 +61,7 @@ protected function lazyLoadMemCachedServers()
6061
* @param string $key The object KEY
6162
* @param int $default IGNORED IN MEMCACHED.
6263
* @return mixed Description
63-
* @throws \Exception
64+
* @throws StorageErrorException
6465
*/
6566
public function get($key, $default = null)
6667
{
@@ -80,7 +81,7 @@ public function get($key, $default = null)
8081
* @param object $value The object to be cached
8182
* @param int $ttl The time to live in seconds of this objects
8283
* @return bool If the object is successfully posted
83-
* @throws \Exception
84+
* @throws StorageErrorException
8485
*/
8586
public function set($key, $value, $ttl = null)
8687
{
@@ -98,7 +99,7 @@ public function set($key, $value, $ttl = null)
9899
/**
99100
* @param string $key
100101
* @return bool
101-
* @throws \Exception
102+
* @throws StorageErrorException
102103
*/
103104
public function delete($key)
104105
{
@@ -117,14 +118,14 @@ public function isAvailable()
117118
try {
118119
$this->lazyLoadMemCachedServers();
119120
return true;
120-
} catch (\Exception $ex) {
121+
} catch (StorageErrorException $ex) {
121122
return false;
122123
}
123124
}
124125

125126
/**
126127
* @return bool
127-
* @throws \Exception
128+
* @throws StorageErrorException
128129
*/
129130
public function clear()
130131
{
@@ -136,7 +137,7 @@ public function clear()
136137
/**
137138
* @param string $key
138139
* @return bool
139-
* @throws \Exception
140+
* @throws StorageErrorException
140141
*/
141142
public function has($key)
142143
{

src/Psr16/ShmopCacheEngine.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace ByJG\Cache\Psr16;
44

5-
use Psr\Cache\InvalidArgumentException;
5+
use ByJG\Cache\Exception\InvalidArgumentException;
6+
use ByJG\Cache\Exception\StorageErrorException;
67
use Psr\Log\NullLogger;
78

89
/**
@@ -125,6 +126,7 @@ protected function isValidAge($file)
125126
* for it or let the driver take care of that.
126127
* @return bool True on success and false on failure.
127128
* @throws InvalidArgumentException
129+
* @throws StorageErrorException
128130
*/
129131
public function set($key, $value, $ttl = null)
130132
{
@@ -136,7 +138,7 @@ public function set($key, $value, $ttl = null)
136138
$size = strlen($serialized);
137139

138140
if ($size > $this->getMaxSize()) {
139-
throw new \ByJG\Cache\InvalidArgumentException('Object is greater than the max size allowed: ' . $this->getMaxSize());
141+
throw new StorageErrorException('Object is greater than the max size allowed: ' . $this->getMaxSize());
140142
}
141143

142144
$file = $this->getFilenameToken($key);
@@ -148,7 +150,7 @@ public function set($key, $value, $ttl = null)
148150
if (isset($lastError['message'])) {
149151
$message = $lastError['message'];
150152
}
151-
throw new \ByJG\Cache\InvalidArgumentException($message);
153+
throw new StorageErrorException($message);
152154
}
153155

154156
$shm_bytes_written = shmop_write($shm_id, $serialized, 0);

src/Psr6/CachePool.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace ByJG\Cache\Psr6;
44

5+
use ByJG\Cache\Exception\InvalidArgumentException;
56
use ByJG\Cache\Psr16\BaseCacheEngine;
67
use Psr\Cache\CacheItemInterface;
78
use Psr\Cache\CacheItemPoolInterface;
8-
use Psr\Log\InvalidArgumentException;
99

1010
class CachePool implements CacheItemPoolInterface
1111
{
@@ -204,7 +204,6 @@ public function deleteItems(array $keys)
204204
* @param CacheItemInterface $item
205205
* @return bool
206206
* @throws \Psr\SimpleCache\InvalidArgumentException
207-
* @throws \Psr\SimpleCache\InvalidArgumentException
208207
*/
209208
public function save(CacheItemInterface $item)
210209
{

0 commit comments

Comments
 (0)