PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.3
Secure Custom Fields v6.9.3
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / vendor / justinrainbow / json-schema / src / JsonSchema / Uri / Retrievers / PredefinedArray.php
secure-custom-fields / vendor / justinrainbow / json-schema / src / JsonSchema / Uri / Retrievers Last commit date
AbstractRetriever.php 9 months ago Curl.php 9 months ago FileGetContents.php 9 months ago PredefinedArray.php 9 months ago UriRetrieverInterface.php 9 months ago
PredefinedArray.php
57 lines
1 <?php
2
3 namespace JsonSchema\Uri\Retrievers;
4
5 use JsonSchema\Validator;
6
7 /**
8 * URI retrieved based on a predefined array of schemas
9 *
10 * @example
11 *
12 * $retriever = new PredefinedArray(array(
13 * 'http://acme.com/schemas/person#' => '{ ... }',
14 * 'http://acme.com/schemas/address#' => '{ ... }',
15 * ))
16 *
17 * $schema = $retriever->retrieve('http://acme.com/schemas/person#');
18 */
19 class PredefinedArray extends AbstractRetriever
20 {
21 /**
22 * Contains schemas as URI => JSON
23 *
24 * @var array
25 */
26 private $schemas;
27
28 /**
29 * Constructor
30 *
31 * @param array $schemas
32 * @param string $contentType
33 */
34 public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
35 {
36 $this->schemas = $schemas;
37 $this->contentType = $contentType;
38 }
39
40 /**
41 * {@inheritdoc}
42 *
43 * @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve()
44 */
45 public function retrieve($uri)
46 {
47 if (!array_key_exists($uri, $this->schemas)) {
48 throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
49 'The JSON schema "%s" was not found.',
50 $uri
51 ));
52 }
53
54 return $this->schemas[$uri];
55 }
56 }
57