@@ -11,5 +11,5 @@ |
||
11 | 11 | * |
12 | 12 | * @package Tests\Cache\Mock |
13 | 13 | */ |
14 | -class AbstractCacheMock extends AbstractCache{ |
|
14 | +class AbstractCacheMock extends AbstractCache { |
|
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -36,7 +36,7 @@ |
||
36 | 36 | { |
37 | 37 | $this->ttl = new \DateInterval('P1M'); |
38 | 38 | $this->memcacheMock = $this->getMockBuilder('\Memcached')->getMock(); |
39 | - $this->memcacheStorage = new MemcacheStorage($this->memcacheMock,'localhost',11211, $this->ttl); |
|
39 | + $this->memcacheStorage = new MemcacheStorage($this->memcacheMock, 'localhost', 11211, $this->ttl); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function testAddServer() |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Tests\Cache; |
4 | 4 | |
5 | -use Ds\Cache\CacheStorageInterface; |
|
6 | 5 | use Ds\Cache\Storage\MemcacheStorage; |
7 | 6 | |
8 | 7 |
@@ -28,35 +28,35 @@ |
||
28 | 28 | /** |
29 | 29 | * |
30 | 30 | */ |
31 | - public function testHas(){ |
|
31 | + public function testHas() { |
|
32 | 32 | $this->assertEquals($this->cacheStorage->has('key', 'value'), false); |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * |
37 | 37 | */ |
38 | - public function testSet(){ |
|
38 | + public function testSet() { |
|
39 | 39 | $this->assertEquals($this->cacheStorage->set('key', 'value', 10), true); |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * |
44 | 44 | */ |
45 | - public function testGet(){ |
|
45 | + public function testGet() { |
|
46 | 46 | $this->assertEquals($this->cacheStorage->get('key'), null); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * |
51 | 51 | */ |
52 | - public function testDelete(){ |
|
52 | + public function testDelete() { |
|
53 | 53 | $this->assertEquals($this->cacheStorage->delete('key'), true); |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * |
58 | 58 | */ |
59 | - public function testClear(){ |
|
59 | + public function testClear() { |
|
60 | 60 | $this->assertEquals($this->cacheStorage->clear(), true); |
61 | 61 | } |
62 | 62 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Test immutable setter AbstractStorage::withTtl |
35 | 35 | */ |
36 | - public function testWithTtl(){ |
|
36 | + public function testWithTtl() { |
|
37 | 37 | $newDateInterval = new \DateInterval('P2M'); |
38 | 38 | $newTtl = $this->abstractStorage->withTtl($newDateInterval); |
39 | 39 | $this->assertNotSame($this->abstractStorage->getTtl(), $newTtl->getTtl()); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * Test getter AbstractStorage::getTtl |
44 | 44 | */ |
45 | - public function testGetTtl(){ |
|
45 | + public function testGetTtl() { |
|
46 | 46 | $ttl = $this->abstractStorage->getTtl(); |
47 | 47 | $this->assertSame($this->ttl, $ttl); |
48 | 48 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Get get ttl when provided with null |
52 | 52 | */ |
53 | - public function testGetTtlTimestampWhenNull(){ |
|
53 | + public function testGetTtlTimestampWhenNull() { |
|
54 | 54 | $dateTime = new \DateTime(); |
55 | - $dateTime->add( $this->ttl ); |
|
55 | + $dateTime->add($this->ttl); |
|
56 | 56 | $expected = $dateTime->getTimestamp(); |
57 | 57 | $actual = $this->abstractStorage->getTtlTimestamp(null); |
58 | 58 | $this->assertEquals($expected, $actual); |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * Test get ttl when provided with an integer. |
63 | 63 | */ |
64 | - public function testGetTtlTimestampWhenInt(){ |
|
65 | - $expected = 60*60*7; |
|
64 | + public function testGetTtlTimestampWhenInt() { |
|
65 | + $expected = 60 * 60 * 7; |
|
66 | 66 | $actual = $this->abstractStorage->getTtlTimestamp($expected); |
67 | 67 | $this->assertEquals($expected, $actual); |
68 | 68 | } |
@@ -31,19 +31,19 @@ |
||
31 | 31 | /** |
32 | 32 | * Test that NullStorage Adaptor is called by default. |
33 | 33 | */ |
34 | - public function testConstructNullStorage(){ |
|
34 | + public function testConstructNullStorage() { |
|
35 | 35 | $cache = new Cache(); |
36 | 36 | $storage = $cache->getCacheStorage(); |
37 | - $this->assertInstanceOf(NullStorage::class,$storage); |
|
37 | + $this->assertInstanceOf(NullStorage::class, $storage); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Test CacheStorage is updated from construct. |
42 | 42 | */ |
43 | - public function testConstructWithStorage(){ |
|
43 | + public function testConstructWithStorage() { |
|
44 | 44 | $cache = new Cache($this->storageMock); |
45 | 45 | $storage = $cache->getCacheStorage(); |
46 | - $this->assertSame($this->storageMock,$storage); |
|
46 | + $this->assertSame($this->storageMock, $storage); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return bool |
69 | 69 | */ |
70 | - public function has($key){ |
|
71 | - if (!empty($this->mmc->get($key))){ |
|
70 | + public function has($key) { |
|
71 | + if (!empty($this->mmc->get($key))) { |
|
72 | 72 | return true; |
73 | 73 | } |
74 | 74 | return false; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return bool True on success and false on failure. |
115 | 115 | */ |
116 | - public function clear(){ |
|
116 | + public function clear() { |
|
117 | 117 | return $this->flush(); |
118 | 118 | } |
119 | 119 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * NullStorage constructor. |
24 | 24 | */ |
25 | - public function __construct(){} |
|
25 | + public function __construct() {} |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return mixed The value of the item from the cache, or $default in case of cache miss. |
49 | 49 | * |
50 | 50 | */ |
51 | - public function get($key){ |
|
51 | + public function get($key) { |
|
52 | 52 | return null; |
53 | 53 | } |
54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public function has($key){ |
|
67 | + public function has($key) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return bool True on success and false on failure. |
87 | 87 | */ |
88 | - public function clear(){ |
|
88 | + public function clear() { |
|
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | } |
@@ -28,16 +28,16 @@ |
||
28 | 28 | * @param DateInterval $ttl |
29 | 29 | * @throws CacheException |
30 | 30 | */ |
31 | - public function __construct(DateInterval $ttl) |
|
32 | - { |
|
33 | - $foundApc = \extension_loaded('apc'); |
|
31 | + public function __construct(DateInterval $ttl) |
|
32 | + { |
|
33 | + $foundApc = \extension_loaded('apc'); |
|
34 | 34 | |
35 | - if (!$foundApc){ |
|
36 | - throw new CacheException('APC Extension not found.'); |
|
37 | - } |
|
35 | + if (!$foundApc){ |
|
36 | + throw new CacheException('APC Extension not found.'); |
|
37 | + } |
|
38 | 38 | |
39 | - parent::__construct($ttl); |
|
40 | - } |
|
39 | + parent::__construct($ttl); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Determines whether an item is present in the cache. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $foundApc = \extension_loaded('apc'); |
34 | 34 | |
35 | - if (!$foundApc){ |
|
35 | + if (!$foundApc) { |
|
36 | 36 | throw new CacheException('APC Extension not found.'); |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public function has($key){ |
|
54 | + public function has($key) { |
|
55 | 55 | return \apc_exists($key); |
56 | 56 | } |
57 | 57 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function delete($key) |
96 | 96 | { |
97 | - if (\apc_exists($key)){ |
|
97 | + if (\apc_exists($key)) { |
|
98 | 98 | \apc_delete($key); |
99 | 99 | } |
100 | 100 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return bool True on success and false on failure. |
106 | 106 | */ |
107 | - public function clear(){ |
|
107 | + public function clear() { |
|
108 | 108 | |
109 | 109 | \apc_clear_cache(); |
110 | 110 | $apcResult = $this->getInfo(); |
111 | 111 | |
112 | - if (!empty($apcResult['cache_list'])){ |
|
112 | + if (!empty($apcResult['cache_list'])) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return array |
124 | 124 | */ |
125 | - public function getInfo(){ |
|
125 | + public function getInfo() { |
|
126 | 126 | return apc_cache_info(); |
127 | 127 | } |
128 | 128 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param DateInterval $ttl |
42 | 42 | * @return CacheStorageInterface |
43 | 43 | */ |
44 | - public function withTtl(DateInterval $ttl){ |
|
44 | + public function withTtl(DateInterval $ttl) { |
|
45 | 45 | $new = clone $this; |
46 | 46 | $new->ttl = $ttl; |
47 | 47 | return $new; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | * @param null|int $ttl |
54 | 54 | * @return int |
55 | 55 | */ |
56 | - public function getTtlTimestamp($ttl = null){ |
|
56 | + public function getTtlTimestamp($ttl = null) { |
|
57 | 57 | |
58 | - if (null === $ttl){ |
|
58 | + if (null === $ttl) { |
|
59 | 59 | $dateTime = new DateTime(); |
60 | - $dateTime->add( $this->ttl ); |
|
60 | + $dateTime->add($this->ttl); |
|
61 | 61 | $ttl = $dateTime->getTimestamp(); |
62 | 62 | } |
63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return DateInterval |
71 | 71 | */ |
72 | - public function getTtl(){ |
|
72 | + public function getTtl() { |
|
73 | 73 | return $this->ttl; |
74 | 74 | } |
75 | 75 |