Replaced all FQ global function and constants by explicit imports

This commit is contained in:
Alejandro Celaya
2018-10-28 08:24:06 +01:00
parent e1222de05b
commit 77d810b735
70 changed files with 235 additions and 123 deletions

View File

@@ -6,6 +6,7 @@ namespace Shlinkio\Shlink\Common;
use const JSON_ERROR_NONE;
use function getenv;
use function in_array;
use function json_decode as spl_json_decode;
use function json_last_error;
use function json_last_error_msg;
use function strtolower;
@@ -50,11 +51,14 @@ function contains($needle, array $haystack): bool
return in_array($needle, $haystack, true);
}
/**
* @throws Exception\InvalidArgumentException
*/
function json_decode(string $json, int $depth = 512, int $options = 0): array
{
$data = \json_decode($json, true, $depth, $options);
$data = spl_json_decode($json, true, $depth, $options);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new Exception\InvalidArgumentException('Error decoding JSON: ' . json_last_error_msg());
throw new Exception\InvalidArgumentException(sprintf('Error decoding JSON: %s', json_last_error_msg()));
}
return $data;