for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Remorhaz\JSON\Path\Query;
use Remorhaz\JSON\Data\Value\NodeValueInterface;
use Remorhaz\JSON\Path\Value\ValueListInterface;
use Remorhaz\JSON\Path\Parser\ParserInterface;
use Remorhaz\JSON\Path\Runtime\RuntimeInterface;
final class LazyQuery implements QueryInterface
{
private $loadedQuery;
private $source;
private $parser;
private $astTranslator;
public function __construct(string $source, ParserInterface $parser, QueryAstTranslatorInterface $astTranslator)
$this->source = $source;
$this->parser = $parser;
$this->astTranslator = $astTranslator;
}
public function __invoke(RuntimeInterface $runtime, NodeValueInterface $rootNode): ValueListInterface
return $this->getLoadedQuery()($runtime, $rootNode);
/**
* @return QueryCapabilitiesInterface
* @deprecated
*/
public function getProperties(): QueryCapabilitiesInterface
return $this->getCapabilities();
public function getCapabilities(): QueryCapabilitiesInterface
return $this
->getLoadedQuery()
->getCapabilities();
public function getSource(): string
return $this->source;
private function getLoadedQuery(): QueryInterface
if (!isset($this->loadedQuery)) {
$this->loadedQuery = $this->loadQuery();
return $this->loadedQuery;
private function loadQuery(): QueryInterface
$queryAst = $this
->parser
->buildQueryAst($this->source);
->astTranslator
->buildQuery($this->source, $queryAst);