@@ -65,7 +65,7 @@ |
||
| 65 | 65 | */ |
| 66 | 66 | public function setApiPath($path) |
| 67 | 67 | { |
| 68 | - $path = strval($path); |
|
| 68 | + $path = strval($path); |
|
| 69 | 69 | $this->apiPath = $path; |
| 70 | 70 | |
| 71 | 71 | return $this; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __construct($baseUrl, $cacheAdapter = 'file') |
| 51 | 51 | { |
| 52 | - $baseUrl = strval($baseUrl); |
|
| 52 | + $baseUrl = strval($baseUrl); |
|
| 53 | 53 | $this->client = new GuzzleClient([ |
| 54 | 54 | 'base_uri' => $baseUrl, |
| 55 | 55 | ]); |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function file($file, $name = null) |
| 69 | 69 | { |
| 70 | - $file = strval($file); |
|
| 71 | - $name = $name === null ? null : strval($name); |
|
| 70 | + $file = strval($file); |
|
| 71 | + $name = $name === null ? null : strval($name); |
|
| 72 | 72 | $this->filePath = $file; |
| 73 | 73 | |
| 74 | 74 | if ( ! file_exists($file) || ! is_readable($file)) { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function setChecksumAlgorithm($algorithm) |
| 184 | 184 | { |
| 185 | - $algorithm = strval($algorithm); |
|
| 185 | + $algorithm = strval($algorithm); |
|
| 186 | 186 | $this->checksumAlgorithm = $algorithm; |
| 187 | 187 | |
| 188 | 188 | return $this; |
@@ -245,15 +245,15 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function upload($bytes = -1) |
| 247 | 247 | { |
| 248 | - $bytes = intval($bytes); |
|
| 248 | + $bytes = intval($bytes); |
|
| 249 | 249 | $bytes = $bytes < 0 ? $this->getFileSize() : $bytes; |
| 250 | 250 | $key = $this->getKey(); |
| 251 | 251 | |
| 252 | 252 | try { |
| 253 | - // Check if this upload exists with HEAD request. |
|
| 254 | - $this->sendHeadRequest($key); |
|
| 253 | + // Check if this upload exists with HEAD request. |
|
| 254 | + $this->sendHeadRequest($key); |
|
| 255 | 255 | } catch (FileException $e) { |
| 256 | - $this->create($key); |
|
| 256 | + $this->create($key); |
|
| 257 | 257 | } catch (ClientException $e) { |
| 258 | 258 | $this->create($key); |
| 259 | 259 | } catch (ConnectException $e) { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | try { |
| 277 | 277 | $offset = $this->sendHeadRequest($key); |
| 278 | 278 | } catch (FileException $e) { |
| 279 | - return false; |
|
| 279 | + return false; |
|
| 280 | 280 | } catch (ClientException $e) { |
| 281 | 281 | return false; |
| 282 | 282 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | public function create($key) |
| 297 | 297 | { |
| 298 | - $key = strval($key); |
|
| 298 | + $key = strval($key); |
|
| 299 | 299 | $headers = [ |
| 300 | 300 | 'Upload-Length' => $this->fileSize, |
| 301 | 301 | 'Upload-Key' => $key, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | public function concat($key, ...$partials) |
| 330 | 330 | { |
| 331 | - $key = strval($key); |
|
| 331 | + $key = strval($key); |
|
| 332 | 332 | $response = $this->getClient()->post($this->apiPath, [ |
| 333 | 333 | 'headers' => [ |
| 334 | 334 | 'Upload-Length' => $this->fileSize, |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | public function delete($key) |
| 363 | 363 | { |
| 364 | - $key = strval($key); |
|
| 364 | + $key = strval($key); |
|
| 365 | 365 | try { |
| 366 | 366 | $this->getClient()->delete($this->apiPath . '/' . $key, [ |
| 367 | 367 | 'headers' => [ |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | protected function partial($state = true) |
| 388 | 388 | { |
| 389 | - $state = boolval($state); |
|
| 389 | + $state = boolval($state); |
|
| 390 | 390 | $this->partial = $state; |
| 391 | 391 | |
| 392 | 392 | if ( ! $this->partial) { |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | protected function sendHeadRequest($key) |
| 415 | 415 | { |
| 416 | - $key = strval($key); |
|
| 416 | + $key = strval($key); |
|
| 417 | 417 | $response = $this->getClient()->head($this->apiPath . '/' . $key); |
| 418 | 418 | $statusCode = $response->getStatusCode(); |
| 419 | 419 | |
@@ -438,8 +438,8 @@ discard block |
||
| 438 | 438 | */ |
| 439 | 439 | protected function sendPatchRequest($key, $bytes) |
| 440 | 440 | { |
| 441 | - $key = strval($key); |
|
| 442 | - $bytes = intval($bytes); |
|
| 441 | + $key = strval($key); |
|
| 442 | + $bytes = intval($bytes); |
|
| 443 | 443 | $data = $this->getData($key, $bytes); |
| 444 | 444 | $headers = [ |
| 445 | 445 | 'Content-Type' => 'application/offset+octet-stream', |
@@ -485,8 +485,8 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | protected function getData($key, $bytes) |
| 487 | 487 | { |
| 488 | - $key = strval($key); |
|
| 489 | - $bytes = intval($bytes); |
|
| 488 | + $key = strval($key); |
|
| 489 | + $bytes = intval($bytes); |
|
| 490 | 490 | $file = new File; |
| 491 | 491 | $handle = $file->open($this->getFilePath(), $file::READ_BINARY); |
| 492 | 492 | $offset = $this->partialOffset; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function header($key, $default = null) |
| 78 | 78 | { |
| 79 | - $key = strval($key); |
|
| 79 | + $key = strval($key); |
|
| 80 | 80 | return $this->request->headers->get($key, $default); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function extractFromHeader($key, $value) |
| 102 | 102 | { |
| 103 | - $key = strval($key); |
|
| 104 | - $value = strval($value); |
|
| 103 | + $key = strval($key); |
|
| 104 | + $value = strval($value); |
|
| 105 | 105 | $meta = $this->header($key); |
| 106 | 106 | |
| 107 | 107 | if (false !== strpos($meta, $value)) { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | return explode(' ', $meta); |
| 111 | 111 | // NOTE: This used to be: "explode(' ', $meta) ?? [];", but |
| 112 | - // explode does not ever return null, and coalesce operator only checks undefined/null |
|
| 112 | + // explode does not ever return null, and coalesce operator only checks undefined/null |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | return []; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function send($content, $status = HttpResponse::HTTP_OK, array $headers = []) |
| 101 | 101 | { |
| 102 | - $status = intval($status); |
|
| 102 | + $status = intval($status); |
|
| 103 | 103 | $headers = array_merge($this->headers, $headers); |
| 104 | 104 | |
| 105 | 105 | if (is_array($content)) { |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT |
| 129 | 129 | ) { |
| 130 | 130 | |
| 131 | - $name = $name === null ? null : strval($name); |
|
| 132 | - $disposition = strval($disposition); |
|
| 131 | + $name = $name === null ? null : strval($name); |
|
| 132 | + $disposition = strval($disposition); |
|
| 133 | 133 | |
| 134 | 134 | $response = new BinaryFileResponse($file, HttpResponse::HTTP_OK, $headers, true, $disposition); |
| 135 | 135 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function get($key, $withExpired = false) |
| 112 | 112 | { |
| 113 | - $key = strval($key); |
|
| 114 | - $withExpired = boolval($withExpired); |
|
| 113 | + $key = strval($key); |
|
| 114 | + $withExpired = boolval($withExpired); |
|
| 115 | 115 | |
| 116 | 116 | $key = $this->getActualCacheKey($key); |
| 117 | 117 | $contents = $this->getCacheContents(); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function set($key, $value) |
| 134 | 134 | { |
| 135 | - $key = strval($key); |
|
| 135 | + $key = strval($key); |
|
| 136 | 136 | |
| 137 | 137 | $key = $this->getActualCacheKey($key); |
| 138 | 138 | $cacheFile = $this->getCacheFile(); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function delete($key) |
| 159 | 159 | { |
| 160 | - $key = strval($key); |
|
| 160 | + $key = strval($key); |
|
| 161 | 161 | |
| 162 | 162 | $key = $this->getActualCacheKey($key); |
| 163 | 163 | $contents = $this->getCacheContents(); |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function isValid($key) |
| 196 | 196 | { |
| 197 | - $key = strval($key); |
|
| 197 | + $key = strval($key); |
|
| 198 | 198 | |
| 199 | 199 | $key = $this->getActualCacheKey($key); |
| 200 | - $contents = $this->getCacheContents(); |
|
| 201 | - $meta = isset($contents[$key]) ? $contents[$key] : []; |
|
| 200 | + $contents = $this->getCacheContents(); |
|
| 201 | + $meta = isset($contents[$key]) ? $contents[$key] : []; |
|
| 202 | 202 | |
| 203 | 203 | if (empty($meta['expires_at'])) { |
| 204 | 204 | return false; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | return false; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - return Json::decodeOrEmptyArray(file_get_contents($cacheFile)); |
|
| 223 | + return Json::decodeOrEmptyArray(file_get_contents($cacheFile)); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function getActualCacheKey($key) |
| 234 | 234 | { |
| 235 | - $key = strval($key); |
|
| 235 | + $key = strval($key); |
|
| 236 | 236 | $prefix = $this->getPrefix(); |
| 237 | 237 | |
| 238 | 238 | if (false === strpos($key, $prefix)) { |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | } else { |
| 30 | 30 | self::$config = require $config; |
| 31 | 31 | if (self::$config === null) { |
| 32 | - self::$config = self::DEFAULT_CONFIG_PATH; |
|
| 32 | + self::$config = self::DEFAULT_CONFIG_PATH; |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Json { |
| 6 | 6 | |
| 7 | - public static function decodeOrEmptyArray($string) { |
|
| 8 | - $decoded = json_decode($string, true); |
|
| 9 | - return $decoded === null ? [] : $decoded; |
|
| 10 | - } |
|
| 7 | + public static function decodeOrEmptyArray($string) { |
|
| 8 | + $decoded = json_decode($string, true); |
|
| 9 | + return $decoded === null ? [] : $decoded; |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | 12 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | public function details() |
| 265 | 265 | { |
| 266 | 266 | $now = Carbon::now(); |
| 267 | - $cache = $this->cache; |
|
| 267 | + $cache = $this->cache; |
|
| 268 | 268 | |
| 269 | 269 | return [ |
| 270 | 270 | 'name' => $this->name, |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | public function upload($totalBytes) |
| 291 | 291 | { |
| 292 | - $totalBytes = intval($totalBytes); |
|
| 292 | + $totalBytes = intval($totalBytes); |
|
| 293 | 293 | $bytesWritten = $this->offset; |
| 294 | 294 | |
| 295 | 295 | if ($bytesWritten === $totalBytes) { |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function open($filePath, $mode) |
| 345 | 345 | { |
| 346 | - $filePath = strval($filePath); |
|
| 347 | - $mode = strval($mode); |
|
| 346 | + $filePath = strval($filePath); |
|
| 347 | + $mode = strval($mode); |
|
| 348 | 348 | $this->exists($filePath, $mode); |
| 349 | 349 | |
| 350 | 350 | $ptr = @fopen($filePath, $mode); |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | public function exists($filePath, $mode = self::READ_BINARY) |
| 370 | 370 | { |
| 371 | - $filePath = strval($filePath); |
|
| 372 | - $mode = strval($mode); |
|
| 371 | + $filePath = strval($filePath); |
|
| 372 | + $mode = strval($mode); |
|
| 373 | 373 | if (self::INPUT_STREAM === $filePath) { |
| 374 | 374 | return true; |
| 375 | 375 | } |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | */ |
| 393 | 393 | public function seek($handle, $offset, $whence = SEEK_SET) |
| 394 | 394 | { |
| 395 | - $offset = intval($offset); |
|
| 396 | - $whence = intval($whence); |
|
| 395 | + $offset = intval($offset); |
|
| 396 | + $whence = intval($whence); |
|
| 397 | 397 | $position = fseek($handle, $offset, $whence); |
| 398 | 398 | |
| 399 | 399 | if (-1 === $position) { |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | */ |
| 416 | 416 | public function read($handle, $chunkSize) |
| 417 | 417 | { |
| 418 | - $chunkSize = intval($chunkSize); |
|
| 418 | + $chunkSize = intval($chunkSize); |
|
| 419 | 419 | |
| 420 | 420 | $data = fread($handle, $chunkSize); |
| 421 | 421 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | public function write($handle, $data, $length = null) |
| 441 | 441 | { |
| 442 | - $data = strval($data); |
|
| 442 | + $data = strval($data); |
|
| 443 | 443 | $bytesWritten = is_int($length) ? fwrite($handle, $data, $length) : fwrite($handle, $data); |
| 444 | 444 | |
| 445 | 445 | if (false === $bytesWritten) { |
@@ -494,8 +494,8 @@ discard block |
||
| 494 | 494 | */ |
| 495 | 495 | public function copy($source, $destination) |
| 496 | 496 | { |
| 497 | - $source = strval($source); |
|
| 498 | - $destination = strval($destination); |
|
| 497 | + $source = strval($source); |
|
| 498 | + $destination = strval($destination); |
|
| 499 | 499 | $status = @copy($source, $destination); |
| 500 | 500 | |
| 501 | 501 | if (false === $status) { |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | public function delete(array $files, $folder = false) |
| 517 | 517 | { |
| 518 | - $folder = boolval($folder); |
|
| 518 | + $folder = boolval($folder); |
|
| 519 | 519 | $status = $this->deleteFiles($files); |
| 520 | 520 | |
| 521 | 521 | if ($status && $folder) { |