for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace League\JsonReference\Loader;
use League\JsonReference\Decoder\JsonDecoder;
use League\JsonReference\DecoderInterface;
use League\JsonReference\LoaderInterface;
use League\JsonReference\SchemaLoadingException;
final class ArrayLoader implements LoaderInterface
{
/**
* @var array
*/
private $schemas;
* @var DecoderInterface
private $jsonDecoder;
* @param array $schemas A map of schemas where path => schema.The schema should be a string or the
* object resulting from a json_decode call.
* @param DecoderInterface $jsonDecoder
public function __construct(array $schemas, DecoderInterface $jsonDecoder = null)
$this->schemas = $schemas;
$this->jsonDecoder = $jsonDecoder ?: new JsonDecoder();
}
* {@inheritdoc}
public function load($path)
if (!array_key_exists($path, $this->schemas)) {
throw SchemaLoadingException::notFound($path);
$schema = $this->schemas[$path];
if (is_string($schema)) {
return $this->jsonDecoder->decode($schema);
} elseif (is_object($schema)) {
return $schema;
} else {
throw SchemaLoadingException::create($path);