final class Snapshot

A coverage snapshot lists every source unit in scope with the semantic fingerprint of the records claiming it, and nothing else: no source text. Comparing the current analysis with the snapshot of a trusted base revision yields the new or changed units, which form the differential denominator, and the units the snapshot lists but the scope no longer contains.

Constants§

public const TYPE = 'requirements-snapshot'

The type written in every coverage snapshot.

Methods§

public function create(
    Analysis $analysis,
    Project $project,
): array{version: int, type: string, units: array<string, array{fingerprint: string}>}

Creates the snapshot of an analysis.

Parameters

$analysisAnalysisThe analysis
$projectProjectThe analyzed project

Returns

array{version: int, type: string, units: array<string, array{fingerprint: string}>} The snapshot document

Throws

JsonException When a record cannot be encoded
Test cases 4
Called from 1
Calls 1
public function read(string $file): array<string, string>

Reads a snapshot file.

Parameters

$filestringThe snapshot file

Returns

array<string, string> The fingerprints by unit key

Throws

InvalidInputException When the file cannot be read, is not a coverage snapshot or lists an invalid unit
JsonException When the file is not JSON
Test cases 9
Called from 1
Calls 8
public function compare(
    Analysis $analysis,
    Project $project,
    array<string, string> $snapshot,
): array{changed: list<string>, removed: list<string>}

Compares an analysis with a snapshot.

Parameters

$analysisAnalysisThe current analysis
$projectProjectThe analyzed project
$snapshotarray<string, string>The fingerprints by unit key

Returns

array{changed: list<string>, removed: list<string>} The new or changed unit keys and the unit keys no longer in scope

Throws

JsonException When a record cannot be encoded
Test cases 3
Called from 1
Calls 3

Test cases 13§

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

Dedicated tests 11
Other tests reaching this symbol 2

Relations§

Instantiated in 2
Method calls 3