@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @package app\framework\Component\Storage\Driver\Local |
29 | 29 | */ |
30 | -class LocalStorageDriver implements SizeAwareInterface,DriverInterface,AbsolutePathInterface,TouchableInterface,DirectoryAwareInterface |
|
30 | +class LocalStorageDriver implements SizeAwareInterface, DriverInterface, AbsolutePathInterface, TouchableInterface, DirectoryAwareInterface |
|
31 | 31 | { |
32 | 32 | /** |
33 | 33 | * @var string |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | function __construct($config) |
65 | 65 | { |
66 | - if(is_array($config)){ |
|
66 | + if (is_array($config)) { |
|
67 | 67 | $config = new ArrayObject($config); |
68 | 68 | } |
69 | 69 | |
70 | - if(!$config instanceof ArrayObject){ |
|
70 | + if (!$config instanceof ArrayObject) { |
|
71 | 71 | throw new StorageException('Storage driver config must be an array or ArrayObject!'); |
72 | 72 | } |
73 | 73 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $this->recentKey = $key; |
123 | 123 | |
124 | - if($this->keyExists($key)){ |
|
124 | + if ($this->keyExists($key)) { |
|
125 | 125 | return filesize($this->buildPath($key)); |
126 | 126 | } |
127 | 127 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $this->recentKey = $key; |
142 | 142 | |
143 | - if($this->keyExists($key)){ |
|
143 | + if ($this->keyExists($key)) { |
|
144 | 144 | return file_get_contents($this->buildPath($key)); |
145 | 145 | } |
146 | 146 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | { |
162 | 162 | $this->recentKey = $key; |
163 | 163 | |
164 | - if($this->keyExists($key)) { |
|
164 | + if ($this->keyExists($key)) { |
|
165 | 165 | return file_put_contents($this->buildPath($key), $contents); |
166 | 166 | } |
167 | 167 | |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | if ($key != '') { |
185 | 185 | $key = ltrim($key, DIRECTORY_SEPARATOR); |
186 | 186 | $key = rtrim($key, DIRECTORY_SEPARATOR); |
187 | - $path = $this->directory . DIRECTORY_SEPARATOR . $key; |
|
187 | + $path = $this->directory.DIRECTORY_SEPARATOR.$key; |
|
188 | 188 | } else { |
189 | 189 | $path = $this->directory; |
190 | 190 | } |
191 | 191 | |
192 | 192 | if (!is_dir($path)) { |
193 | - return []; |
|
193 | + return [ ]; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | if ($recursive) { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | $files = iterator_to_array($iterator); |
210 | 210 | } else { |
211 | - $files = []; |
|
211 | + $files = [ ]; |
|
212 | 212 | $iterator = new DirectoryIterator($path); |
213 | 213 | |
214 | 214 | foreach ($iterator as $fileInfo) { |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | continue; |
219 | 219 | } |
220 | 220 | |
221 | - $files[] = $fileInfo->getPathname(); |
|
221 | + $files[ ] = $fileInfo->getPathname(); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | - $keys = []; |
|
225 | + $keys = [ ]; |
|
226 | 226 | |
227 | 227 | foreach ($files as $file) { |
228 | - $keys[] = $this->helper->getKey($file, $this->directory); |
|
228 | + $keys[ ] = $this->helper->getKey($file, $this->directory); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | sort($keys); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | $this->recentKey = $key; |
247 | 247 | |
248 | - if($this->keyExists($key)){ |
|
248 | + if ($this->keyExists($key)) { |
|
249 | 249 | return filectime($this->buildPath($key)); |
250 | 250 | } |
251 | 251 | |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | { |
303 | 303 | $file = fopen($this->buildPath($key), "w"); |
304 | 304 | |
305 | - if (! $file) { |
|
305 | + if (!$file) { |
|
306 | 306 | throw new StorageException(StorageException::COULD_NOT_CREATE_FILE, $key); |
307 | 307 | } |
308 | 308 | |
309 | - fwrite($file,""); |
|
309 | + fwrite($file, ""); |
|
310 | 310 | fclose($file); |
311 | 311 | |
312 | 312 | return true; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | { |
334 | 334 | $key = str_replace('\\', '/', $key); |
335 | 335 | |
336 | - return $this->publicUrl . '/' . ltrim($key, "/"); |
|
336 | + return $this->publicUrl.'/'.ltrim($key, "/"); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -56,25 +56,25 @@ |
||
56 | 56 | function __construct($message, $params = null) |
57 | 57 | { |
58 | 58 | $code = 0; |
59 | - if($this->isNumber($message)) { |
|
59 | + if ($this->isNumber($message)) { |
|
60 | 60 | $code = $message; |
61 | - if($code < 100) { |
|
61 | + if ($code < 100) { |
|
62 | 62 | //build-in range |
63 | - if($this->is(self::$coreMessages)) { |
|
64 | - $message = self::$coreMessages[$code]; |
|
63 | + if ($this->is(self::$coreMessages)) { |
|
64 | + $message = self::$coreMessages[ $code ]; |
|
65 | 65 | } else { |
66 | - $message = 'Unknown exception message for the given code "' . $code . '".'; |
|
66 | + $message = 'Unknown exception message for the given code "'.$code.'".'; |
|
67 | 67 | } |
68 | 68 | } else { |
69 | - if($this->is(static::$messages[$code])) { |
|
70 | - $message = static::$messages[$code]; |
|
69 | + if ($this->is(static::$messages[ $code ])) { |
|
70 | + $message = static::$messages[ $code ]; |
|
71 | 71 | } else { |
72 | - $message = 'Unknown exception message for the given code "' . $code . '".'; |
|
72 | + $message = 'Unknown exception message for the given code "'.$code.'".'; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - if(!$this->isNull($params)) { |
|
77 | + if (!$this->isNull($params)) { |
|
78 | 78 | $message = str($message)->format($params)->val(); |
79 | 79 | } |
80 | 80 |