Completed
Branch master (bf78fd)
by smiley
02:32 queued 47s
created
src/Cache.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\SimpleCache\Drivers\CacheDriverInterface;
16 16
 use Psr\SimpleCache\CacheInterface;
17 17
 
18
-class Cache implements CacheInterface{
18
+class Cache implements CacheInterface {
19 19
 
20 20
 	/**
21 21
 	 * @var \chillerlan\SimpleCache\Drivers\CacheDriverInterface
@@ -27,38 +27,38 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param \chillerlan\SimpleCache\Drivers\CacheDriverInterface $cacheDriver
29 29
 	 */
30
-	public function __construct(CacheDriverInterface $cacheDriver){
30
+	public function __construct(CacheDriverInterface $cacheDriver) {
31 31
 		$this->cacheDriver = $cacheDriver;
32 32
 	}
33 33
 
34 34
 	/** @inheritdoc */
35
-	public function get($key, $default = null){
35
+	public function get($key, $default = null) {
36 36
 		$this->checkKey($key);
37 37
 
38 38
 		return $this->cacheDriver->get($key, $default);
39 39
 	}
40 40
 
41 41
 	/** @inheritdoc */
42
-	public function set($key, $value, $ttl = null){
42
+	public function set($key, $value, $ttl = null) {
43 43
 		$this->checkKey($key);
44 44
 
45 45
 		return $this->cacheDriver->set($key, $value, $this->getTTL($ttl));
46 46
 	}
47 47
 
48 48
 	/** @inheritdoc */
49
-	public function delete($key){
49
+	public function delete($key) {
50 50
 		$this->checkKey($key);
51 51
 
52 52
 		return $this->cacheDriver->delete($key);
53 53
 	}
54 54
 
55 55
 	/** @inheritdoc */
56
-	public function clear(){
56
+	public function clear() {
57 57
 		return $this->cacheDriver->clear();
58 58
 	}
59 59
 
60 60
 	/** @inheritdoc */
61
-	public function getMultiple($keys, $default = null){
61
+	public function getMultiple($keys, $default = null) {
62 62
 		$keys = $this->getData($keys);
63 63
 		$this->checkKeyArray($keys);
64 64
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	/** @inheritdoc */
69
-	public function setMultiple($values, $ttl = null){
69
+	public function setMultiple($values, $ttl = null) {
70 70
 		$values = $this->getData($values);
71 71
 
72
-		foreach($values as $key => $value){
72
+		foreach ($values as $key => $value) {
73 73
 			$this->checkKey($key);
74 74
 		}
75 75
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	}
78 78
 
79 79
 	/** @inheritdoc */
80
-	public function deleteMultiple($keys){
80
+	public function deleteMultiple($keys) {
81 81
 		$keys = $this->getData($keys);
82 82
 		$this->checkKeyArray($keys);
83 83
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	/** @inheritdoc */
88
-	public function has($key){
88
+	public function has($key) {
89 89
 		$this->checkKey($key);
90 90
 
91 91
 		return $this->cacheDriver->has($key);
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @return void
98 98
 	 * @throws \chillerlan\SimpleCache\SimpleCacheInvalidArgumentException
99 99
 	 */
100
-	protected function checkKey($key){
100
+	protected function checkKey($key) {
101 101
 
102
-		if(!is_string($key) || empty($key)){
102
+		if (!is_string($key) || empty($key)) {
103 103
 			throw new SimpleCacheInvalidArgumentException('invalid key');
104 104
 		}
105 105
 
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return void
112 112
 	 */
113
-	protected function checkKeyArray(array $keys){
113
+	protected function checkKeyArray(array $keys) {
114 114
 
115
-		foreach($keys as $key){
115
+		foreach ($keys as $key) {
116 116
 			$this->checkKey($key);
117 117
 		}
118 118
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function getData($data):array{
128 128
 
129
-		if($data instanceof \Traversable){
129
+		if ($data instanceof \Traversable) {
130 130
 			return iterator_to_array($data); // @codeCoverageIgnore
131 131
 		}
132
-		else if(is_array($data)){
132
+		else if (is_array($data)) {
133 133
 			return $data;
134 134
 		}
135 135
 
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 	 * @return int|null
143 143
 	 * @throws \chillerlan\SimpleCache\SimpleCacheInvalidArgumentException
144 144
 	 */
145
-	protected function getTTL($ttl){
145
+	protected function getTTL($ttl) {
146 146
 
147
-		if($ttl instanceof \DateInterval){
147
+		if ($ttl instanceof \DateInterval) {
148 148
 			return (new \DateTime('now'))->add($ttl)->getTimeStamp() - time();
149 149
 		}
150
-		else if(is_int($ttl) || is_null($ttl)){
150
+		else if (is_int($ttl) || is_null($ttl)) {
151 151
 			return $ttl;
152 152
 		}
153 153
 
Please login to merge, or discard this patch.