Skip to content

Commit 13fda16

Browse files
authored
Remove dependency on cache/common (#137)
* Remove dependency on cache/common This will fix php-cache/issues#89 * bugfix
1 parent d985c50 commit 13fda16

File tree

3 files changed

+17
-47
lines changed

3 files changed

+17
-47
lines changed

EncryptedCachePool.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
namespace Cache\Encryption;
1313

14-
use Cache\Adapter\Common\PhpCacheItem;
15-
use Cache\Adapter\Common\PhpCachePool;
14+
use Cache\TagInterop\TaggableCacheItemPoolInterface;
1615
use Defuse\Crypto\Key;
1716
use Psr\Cache\CacheItemInterface;
1817
use Psr\Cache\InvalidArgumentException;
@@ -22,10 +21,10 @@
2221
*
2322
* @author Daniel Bannert <[email protected]>
2423
*/
25-
class EncryptedCachePool implements PhpCachePool
24+
class EncryptedCachePool implements TaggableCacheItemPoolInterface
2625
{
2726
/**
28-
* @type PhpCachePool
27+
* @type TaggableCacheItemPoolInterface
2928
*/
3029
private $cachePool;
3130

@@ -35,10 +34,10 @@ class EncryptedCachePool implements PhpCachePool
3534
private $key;
3635

3736
/**
38-
* @param PhpCachePool $cachePool
39-
* @param Key $key
37+
* @param TaggableCacheItemPoolInterface $cachePool
38+
* @param Key $key
4039
*/
41-
public function __construct(PhpCachePool $cachePool, Key $key)
40+
public function __construct(TaggableCacheItemPoolInterface $cachePool, Key $key)
4241
{
4342
$this->cachePool = $cachePool;
4443
$this->key = $key;
@@ -59,7 +58,7 @@ public function getItem($key)
5958
*/
6059
public function getItems(array $keys = [])
6160
{
62-
return array_map(function (PhpCacheItem $inner) {
61+
return array_map(function (CacheItemInterface $inner) {
6362
if (!($inner instanceof EncryptedItemDecorator)) {
6463
return new EncryptedItemDecorator($inner, $this->key);
6564
}

EncryptedItemDecorator.php

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111

1212
namespace Cache\Encryption;
1313

14-
use Cache\Adapter\Common\PhpCacheItem;
14+
use Cache\TagInterop\TaggableCacheItemInterface;
1515
use Defuse\Crypto\Crypto;
1616
use Defuse\Crypto\Key;
17-
use Psr\Cache\CacheItemInterface;
1817

1918
/**
2019
* Encrypt and Decrypt all the stored items.
2120
*
2221
* @author Daniel Bannert <[email protected]>
2322
*/
24-
class EncryptedItemDecorator implements PhpCacheItem
23+
class EncryptedItemDecorator implements TaggableCacheItemInterface
2524
{
2625
/**
2726
* The cacheItem should always contain encrypted data.
2827
*
29-
* @type PhpCacheItem
28+
* @type TaggableCacheItemInterface
3029
*/
3130
private $cacheItem;
3231

@@ -36,10 +35,10 @@ class EncryptedItemDecorator implements PhpCacheItem
3635
private $key;
3736

3837
/**
39-
* @param PhpCacheItem $cacheItem
40-
* @param Key $key
38+
* @param TaggableCacheItemInterface $cacheItem
39+
* @param Key $key
4140
*/
42-
public function __construct(PhpCacheItem $cacheItem, Key $key)
41+
public function __construct(TaggableCacheItemInterface $cacheItem, Key $key)
4342
{
4443
$this->cacheItem = $cacheItem;
4544
$this->key = $key;
@@ -54,7 +53,7 @@ public function getKey()
5453
}
5554

5655
/**
57-
* @return PhpCacheItem
56+
* @return TaggableCacheItemInterface
5857
*/
5958
public function getCacheItem()
6059
{
@@ -101,14 +100,6 @@ public function isHit()
101100
return $this->cacheItem->isHit();
102101
}
103102

104-
/**
105-
* {@inheritdoc}
106-
*/
107-
public function getExpirationTimestamp()
108-
{
109-
return $this->cacheItem->getExpirationTimestamp();
110-
}
111-
112103
/**
113104
* {@inheritdoc}
114105
*/
@@ -137,16 +128,6 @@ public function getPreviousTags()
137128
return $this->cacheItem->getPreviousTags();
138129
}
139130

140-
/**
141-
* Get the current tags. These are not the same tags as getPrevious tags.
142-
*
143-
* @return array
144-
*/
145-
public function getTags()
146-
{
147-
return $this->cacheItem->getTags();
148-
}
149-
150131
/**
151132
* {@inheritdoc}
152133
*/
@@ -158,15 +139,15 @@ public function setTags(array $tags)
158139
}
159140

160141
/**
161-
* Creating a copy of the orginal CacheItemInterface object.
142+
* Creating a copy of the original CacheItemInterface object.
162143
*/
163144
public function __clone()
164145
{
165146
$this->cacheItem = clone $this->cacheItem;
166147
}
167148

168149
/**
169-
* Transfrom value back to it orginal type.
150+
* Transform value back to it original type.
170151
*
171152
* @param array $item
172153
*
@@ -184,14 +165,4 @@ private function transform(array $item)
184165

185166
return $value;
186167
}
187-
188-
/**
189-
* Move tags from $tags to $prevTags.
190-
*
191-
* @internal This function should never be used and considered private.
192-
*/
193-
public function moveTagsToPrevious()
194-
{
195-
$this->cacheItem->moveTagsToPrevious();
196-
}
197168
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"require": {
3232
"php": "^5.5 || ^7.0",
3333
"defuse/php-encryption": "^2.0",
34-
"cache/adapter-common": "^0.4",
34+
"cache/tag-interop": "^1.0",
3535
"psr/cache": "^1.0"
3636
},
3737
"require-dev": {

0 commit comments

Comments
 (0)