diff options
Diffstat (limited to 'server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers')
5 files changed, 0 insertions, 281 deletions
diff --git a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.php b/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.php deleted file mode 100644 index f924ad8..0000000 --- a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * JsonSchema - * @filesource - */ -namespace JsonSchema\Uri\Retrievers; - -/** - * AbstractRetriever implements the default shared behavior - * that all decendant Retrievers should inherit - * @author Steven Garcia <webwhammy@gmail.com> - */ -abstract class AbstractRetriever implements UriRetrieverInterface -{ - /** - * Media content type - * @var string - */ - protected $contentType; - - /** - * {@inheritDoc} - * @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::getContentType() - */ - public function getContentType() - { - return $this->contentType; - } -} diff --git a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php b/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php deleted file mode 100644 index cd8414f..0000000 --- a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -/* - * This file is part of the JsonSchema package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace JsonSchema\Uri\Retrievers; - -use JsonSchema\Validator; - -/** - * Tries to retrieve JSON schemas from a URI using cURL library - * - * @author Sander Coolen <sander@jibber.nl> - */ -class Curl extends AbstractRetriever -{ - protected $messageBody; - - public function __construct() - { - if (!function_exists('curl_init')) { - throw new \RuntimeException("cURL not installed"); - } - } - - /** - * {@inheritDoc} - * @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve() - */ - public function retrieve($uri) - { - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $uri); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE)); - - $response = curl_exec($ch); - if (false === $response) { - throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found'); - } - - $this->fetchMessageBody($response); - $this->fetchContentType($response); - - curl_close($ch); - - return $this->messageBody; - } - - /** - * @param string $response cURL HTTP response - */ - private function fetchMessageBody($response) - { - preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match); - $this->messageBody = $match[1]; - } - - /** - * @param string $response cURL HTTP response - * @return boolean Whether the Content-Type header was found or not - */ - protected function fetchContentType($response) - { - if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) { - $this->contentType = trim($match[1]); - - return true; - } - - return false; - } -}
\ No newline at end of file diff --git a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php b/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php deleted file mode 100644 index bc43de6..0000000 --- a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php - -/* - * This file is part of the JsonSchema package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace JsonSchema\Uri\Retrievers; - -use JsonSchema\Exception\ResourceNotFoundException; -use JsonSchema\Validator; - -/** - * Tries to retrieve JSON schemas from a URI using file_get_contents() - * - * @author Sander Coolen <sander@jibber.nl> - */ -class FileGetContents extends AbstractRetriever -{ - protected $messageBody; - - /** - * {@inheritDoc} - * @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve() - */ - public function retrieve($uri) - { - $context = stream_context_create(array( - 'http' => array( - 'method' => 'GET', - 'header' => "Accept: " . Validator::SCHEMA_MEDIA_TYPE - ))); - - set_error_handler(function() use ($uri) { - throw new ResourceNotFoundException('JSON schema not found at ' . $uri); - }); - $response = file_get_contents($uri); - restore_error_handler(); - - if (false === $response) { - throw new ResourceNotFoundException('JSON schema not found at ' . $uri); - } - if ($response == '' - && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/' - ) { - throw new ResourceNotFoundException('JSON schema not found at ' . $uri); - } - - $this->messageBody = $response; - if (! empty($http_response_header)) { - $this->fetchContentType($http_response_header); - } else { - // Could be a "file://" url or something else - fake up the response - $this->contentType = null; - } - - return $this->messageBody; - } - - /** - * @param array $headers HTTP Response Headers - * @return boolean Whether the Content-Type header was found or not - */ - private function fetchContentType(array $headers) - { - foreach ($headers as $header) { - if ($this->contentType = self::getContentTypeMatchInHeader($header)) { - return true; - } - } - - return false; - } - - /** - * @param string $header - * @return string|null - */ - protected static function getContentTypeMatchInHeader($header) - { - if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) { - return trim($match[1]); - } - } -} diff --git a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php b/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php deleted file mode 100644 index 7652c42..0000000 --- a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -namespace JsonSchema\Uri\Retrievers; - -use JsonSchema\Validator; - -/** - * URI retrieved based on a predefined array of schemas - * - * @example - * - * $retriever = new PredefinedArray(array( - * 'http://acme.com/schemas/person#' => '{ ... }', - * 'http://acme.com/schemas/address#' => '{ ... }', - * )) - * - * $schema = $retriever->retrieve('http://acme.com/schemas/person#'); - */ -class PredefinedArray extends AbstractRetriever -{ - /** - * Contains schemas as URI => JSON - * @var array - */ - private $schemas; - - /** - * Constructor - * - * @param array $schemas - * @param string $contentType - */ - public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE) - { - $this->schemas = $schemas; - $this->contentType = $contentType; - } - - /** - * {@inheritDoc} - * @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve() - */ - public function retrieve($uri) - { - if (!array_key_exists($uri, $this->schemas)) { - throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf( - 'The JSON schema "%s" was not found.', - $uri - )); - } - - return $this->schemas[$uri]; - } -} diff --git a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php b/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php deleted file mode 100644 index c324998..0000000 --- a/server/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -/* - * This file is part of the JsonSchema package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace JsonSchema\Uri\Retrievers; - -/** - * Interface for URI retrievers - * - * @author Sander Coolen <sander@jibber.nl> - */ -interface UriRetrieverInterface -{ - /** - * Retrieve a schema from the specified URI - * @param string $uri URI that resolves to a JSON schema - * @throws \JsonSchema\Exception\ResourceNotFoundException - * @return mixed string|null - */ - public function retrieve($uri); - - /** - * Get media content type - * @return string - */ - public function getContentType(); -}
\ No newline at end of file |
