diff options
| author | Eole <EoleDev@outlook.fr> | 2016-04-27 16:42:28 +0200 |
|---|---|---|
| committer | Eole <EoleDev@outlook.fr> | 2016-04-27 16:42:28 +0200 |
| commit | 49f416dc5061032e0514ea0cfeceaca37d13e432 (patch) | |
| tree | 1202ac2a6fa860b8929afdc886c94fc50bd0a1de /server/vendor/php-opencloud/common/src/Common/Transport/Utils.php | |
| parent | c7edd70b5e5b0f5159c78ce3d924d4e7f60db816 (diff) | |
| parent | c9202d9113210981ae47df40511645da2ee140df (diff) | |
Merge branch 'develop' into Eole_Graph
Conflicts:
client/index.html
client/js/controllers/home/home.js
client/partials/home/home.html
Diffstat (limited to 'server/vendor/php-opencloud/common/src/Common/Transport/Utils.php')
| -rw-r--r-- | server/vendor/php-opencloud/common/src/Common/Transport/Utils.php | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php b/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php deleted file mode 100644 index c2a2dc1..0000000 --- a/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -namespace OpenCloud\Common\Transport; - -use function GuzzleHttp\Psr7\uri_for; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\UriInterface; - -class Utils -{ - public static function jsonDecode(ResponseInterface $response, $assoc = true) - { - $jsonErrors = [ - JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded', - JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch', - JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found', - JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON', - JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded' - ]; - - $responseBody = (string) $response->getBody(); - - if (strlen($responseBody) === 0) { - return $responseBody; - } - - $data = json_decode($responseBody, $assoc); - - if (JSON_ERROR_NONE !== json_last_error()) { - $last = json_last_error(); - throw new \InvalidArgumentException( - 'Unable to parse JSON data: ' . (isset($jsonErrors[$last]) ? $jsonErrors[$last] : 'Unknown error') - ); - } - - return $data; - } - - /** - * Method for flattening a nested array. - * - * @param array $data The nested array - * @param null $key The key to extract - * - * @return array - */ - public static function flattenJson($data, $key = null) - { - return (!empty($data) && $key && isset($data[$key])) ? $data[$key] : $data; - } - - /** - * Method for normalize an URL string. - * - * Append the http:// prefix if not present, and add a - * closing url separator when missing. - * - * @param string $url The url representation. - * - * @return string - */ - public static function normalizeUrl($url) - { - if (strpos($url, 'http') === false) { - $url = 'http://' . $url; - } - - return rtrim($url, '/') . '/'; - } - - /** - * Add an unlimited list of paths to a given URI. - * - * @param UriInterface $uri - * @param ...$paths - * - * @return UriInterface - */ - public static function addPaths(UriInterface $uri, ...$paths) - { - return uri_for(rtrim((string) $uri, '/') . '/' . implode('/', $paths)); - } - - public static function appendPath(UriInterface $uri, $path) - { - return uri_for(rtrim((string) $uri, '/') . '/' . $path); - } -} |
