Skip to content

Commit ad9276e

Browse files
Applied style fixes
1 parent bfd1927 commit ad9276e

5 files changed

Lines changed: 37 additions & 21 deletions

TaggablePSR6ItemAdapter.php

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

1212
namespace Cache\Taggable;
1313

14-
use Cache\Taggable\TaggableItemInterface;
15-
use Cache\Taggable\TaggablePoolInterface;
16-
use Cache\Taggable\TaggablePoolTrait;
1714
use Psr\Cache\CacheItemInterface;
18-
use Psr\Cache\CacheItemPoolInterface;
1915

2016
/**
2117
* @internal
@@ -31,7 +27,7 @@
3127
class TaggablePSR6ItemAdapter implements TaggableItemInterface
3228
{
3329
/**
34-
* @type boolean
30+
* @type bool
3531
*/
3632
private $initialized = false;
3733

@@ -55,6 +51,7 @@ private function __construct(CacheItemInterface $cacheItem)
5551

5652
/**
5753
* @param CacheItemInterface $cacheItem
54+
*
5855
* @return TaggableItemInterface
5956
*/
6057
public static function makeTaggable(CacheItemInterface $cacheItem)
@@ -88,8 +85,6 @@ public function get()
8885
if (is_array($rawItem) && isset($rawItem['value'])) {
8986
return $rawItem['value'];
9087
}
91-
92-
return null;
9388
}
9489

9590
/**
@@ -109,7 +104,7 @@ public function set($value)
109104

110105
$this->cacheItem->set([
111106
'value' => $value,
112-
'tags' => $this->tags,
107+
'tags' => $this->tags,
113108
]);
114109

115110
return $this;
@@ -121,6 +116,7 @@ public function set($value)
121116
public function getTags()
122117
{
123118
$this->initializeTags();
119+
124120
return $this->tags;
125121
}
126122

@@ -130,7 +126,7 @@ public function getTags()
130126
public function setTags(array $tags)
131127
{
132128
$this->initialized = true;
133-
$this->tags = $tags;
129+
$this->tags = $tags;
134130
$this->updateTags();
135131

136132
return $this;
@@ -154,6 +150,7 @@ public function addTag($tag)
154150
public function expiresAt($expiration)
155151
{
156152
$this->cacheItem->expiresAt($expiration);
153+
157154
return $this;
158155
}
159156

@@ -163,14 +160,15 @@ public function expiresAt($expiration)
163160
public function expiresAfter($time)
164161
{
165162
$this->cacheItem->expiresAfter($time);
163+
166164
return $this;
167165
}
168166

169167
private function updateTags()
170168
{
171169
$this->cacheItem->set([
172170
'value' => $this->get(),
173-
'tags' => $this->tags,
171+
'tags' => $this->tags,
174172
]);
175173
}
176174

TaggablePSR6PoolAdapter.php

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

1212
namespace Cache\Taggable;
1313

14-
use Cache\Taggable\TaggableItemInterface;
15-
use Cache\Taggable\TaggablePoolInterface;
16-
use Cache\Taggable\TaggablePoolTrait;
1714
use Psr\Cache\CacheItemInterface;
1815
use Psr\Cache\CacheItemPoolInterface;
1916

@@ -67,14 +64,14 @@ private function __construct(CacheItemPoolInterface $cachePool, CacheItemPoolInt
6764
}
6865

6966
/**
70-
* @param CacheItemPoolInterface $cachePool The pool to which to add tagging capabilities.
67+
* @param CacheItemPoolInterface $cachePool The pool to which to add tagging capabilities.
7168
* @param CacheItemPoolInterface|null $tagStorePool The pool to store tags in. If null is passed, the main pool is used.
7269
*
7370
* @return TaggablePoolInterface
7471
*/
7572
public static function makeTaggable(CacheItemPoolInterface $cachePool, CacheItemPoolInterface $tagStorePool = null)
7673
{
77-
if ($cachePool instanceOf TaggablePoolInterface && $tagStorePool === null) {
74+
if ($cachePool instanceof TaggablePoolInterface && $tagStorePool === null) {
7875
return $cachePool;
7976
}
8077

@@ -92,7 +89,7 @@ public function getItem($key)
9289
/**
9390
* {@inheritdoc}
9491
*/
95-
public function getItems(array $keys = array())
92+
public function getItems(array $keys = [])
9693
{
9794
$items = $this->cachePool->getItems($keys);
9895

@@ -118,6 +115,7 @@ public function hasItem($key)
118115
public function clear()
119116
{
120117
$ret = $this->cachePool->clear();
118+
121119
return $this->tagStorePool->clear() && $ret; // Is this acceptable?
122120
}
123121

@@ -127,6 +125,7 @@ public function clear()
127125
public function deleteItem($key)
128126
{
129127
$this->preRemoveItem($key);
128+
130129
return $this->cachePool->deleteItem($key);
131130
}
132131

@@ -148,6 +147,7 @@ public function deleteItems(array $keys)
148147
public function save(CacheItemInterface $item)
149148
{
150149
$this->saveTags($item);
150+
151151
return $this->cachePool->save($item->unwrap());
152152
}
153153

@@ -157,6 +157,7 @@ public function save(CacheItemInterface $item)
157157
public function saveDeferred(CacheItemInterface $item)
158158
{
159159
$this->saveTags($item);
160+
160161
return $this->cachePool->saveDeferred($item->unwrap());
161162
}
162163

TaggablePoolTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ abstract protected function appendListItem($name, $key);
6262
abstract protected function removeListItem($name, $key);
6363

6464
/**
65-
* @param array $keys
66-
65+
* @param array $keys
6766
* @throws InvalidArgumentException
6867
*
6968
* @return bool

Tests/SameTagPoolTaggablePSR6AdapterTest.php

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

3+
/*
4+
* This file is part of php-cache organization.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Cache\Taggable\Tests;
413

514
use Cache\IntegrationTests\TaggableCachePoolTest;
@@ -10,6 +19,6 @@ class SameTagPoolTaggablePSR6AdapterTest extends TaggableCachePoolTest
1019
{
1120
public function createCachePool()
1221
{
13-
return TaggablePSR6PoolAdapter::makeTaggable(new SymfonyArrayAdapter);
22+
return TaggablePSR6PoolAdapter::makeTaggable(new SymfonyArrayAdapter());
1423
}
1524
}
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
<?php
22

3+
/*
4+
* This file is part of php-cache organization.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Cache\Taggable\Tests;
413

514
use Cache\IntegrationTests\TaggableCachePoolTest;
615
use Cache\Taggable\TaggablePSR6PoolAdapter;
716
use Symfony\Component\Cache\Adapter\ArrayAdapter as SymfonyArrayAdapter;
817

9-
class SeparateTagPoolTaggablePSR6AdapterTest extends TaggableCachePoolTest
18+
class SeparateTagPoolPSR6AdapterTest extends TaggableCachePoolTest
1019
{
1120
public function createCachePool()
1221
{
13-
return TaggablePSR6PoolAdapter::makeTaggable(new SymfonyArrayAdapter, new SymfonyArrayAdapter);
22+
return TaggablePSR6PoolAdapter::makeTaggable(new SymfonyArrayAdapter(), new SymfonyArrayAdapter());
1423
}
1524
}

0 commit comments

Comments
 (0)