final class Source
Public API: explicitly declared with @visibility public.

A source document a definition quotes, and the scope of units that coverage counts.

The URI is an HTTP(S) URL or a path relative to the configuration; a pinned snapshot is a local copy verified by its SHA-256 digest. The format names the source extension and the selector declares the coverage scope in that extension's syntax.

Declaring an HTML scopedoctest
$source = new \Requirements\Model\Source('manual', 'https://example.org/manual.html', 'html', 'main p');
    [$source->id, $source->format, $source->selector, $source->snapshot] // => ['manual', 'html', 'main p', null]
Reading the source of a definitiondoctest
$source = \Requirements\Model\Source::from(['id' => 'notes', 'uri' => 'notes.txt', 'format' => 'text', 'selector' => 'lines:1-3', 'options' => ['encoding' => 'utf-8']]);
    [$source->uri, $source->options] // => ['notes.txt', ['encoding' => 'utf-8']]
Rejecting a snapshot without its digestdoctest
\Requirements\Model\Source::from(['id' => 'manual', 'uri' => 'https://example.org/', 'format' => 'html', 'selector' => 'p', 'snapshot' => 'cache/manual.html']) // throws \Requirements\Input\InvalidInputException: SHA-256

Properties§

public string $id
public string $uri
public string $format
public string $selector
public string|null $snapshot = null
public string|null $sha256 = null
public array<string, mixed> $options = []

Methods§

public function __construct(
    public string $id,
    public string $uri,
    public string $format,
    public string $selector,
    public string|null $snapshot = null,
    public string|null $sha256 = null,
    public array<string, mixed> $options = [],
)

Parameters

$idstringThe source identifier used by coverage thresholds and reports
$uristringThe HTTP(S) URL or local path of the document
$formatstringThe source extension that reads the document
$selectorstringThe coverage scope in the extension's selector syntax
$snapshotstring|nullThe local copy read instead of the URI unless live
$sha256string|nullThe lowercase SHA-256 digest of the document
$optionsarray<string, mixed>Extension-specific options

Test cases 153§

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

Dedicated tests 6
Other tests reaching this symbol 147

Relations§

Instantiated in 1
Static calls 2
Type declarations 13