for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace League\JsonReference\ScopeResolver;
use League\JsonReference\ScopeResolverInterface;
use function League\JsonReference\pointer;
use function League\JsonReference\pointer_push;
use function League\JsonReference\resolve_uri;
final class JsonSchemaScopeResolver implements ScopeResolverInterface
{
const KEYWORD_DRAFT_4 = 'id';
const KEYWORD_DRAFT_6 = '$id';
/**
* @var string
*/
private $keyword;
* @param string $keyword
public function __construct($keyword)
$this->keyword = $keyword;
}
* {@inheritdoc}
public function resolve($schema, $currentPointer, $currentScope)
$pointer = pointer($schema);
$currentPath = '';
foreach (explode('/', $currentPointer) as $segment) {
if (!empty($segment)) {
$currentPath = pointer_push($currentPath, $segment);
$id = $pointer->getRaw($currentPath . '/' . $this->keyword);
if (is_string($id)) {
$currentScope = resolve_uri($id, $currentScope);
return $currentScope;