final class JsonSource
    implements SourceExtension

Selects values of a JSON source with a subset of JSONPath.

A string value is its own text; any other value is its JSON encoding. Units are located by their JSON Pointer.

Methods§

public function __construct(private ResourceLoader $loader = new \Requirements\Source\ResourceLoader())

Parameters

$loaderResourceLoaderReads the source document
Calls 1
public function select(
    Source $source,
    string $selector,
    string $directory,
    bool $live,
): list<Unit>

Selects the values a JSONPath matches.

Parameters

$sourceSourceThe source declaration
$selectorstringThe JSONPath
$directorystringThe configuration directory
$liveboolWhether to read the current URI instead of a pinned snapshot

Returns

list<Unit> One unit per matched value, located as json:POINTER

Throws

JsonException When the source is not JSON
RuntimeException When the path is unsupported or the source cannot be read
Test cases 7
Calls 9

Private surface 1§

Implementation details, listed for orientation only.

private ResourceLoader $loader = new \Requirements\Source\ResourceLoader()

Test cases 20§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 7
Other tests reaching this symbol 13

Relations§

Instantiated in 1