Greenlight

Documentation

API reference

On this page

Coverage API

This reference lists coverage maps and per-file line coverage values.

These signatures are the public API.

CoverageMap

Namespace: Greenlight\Coverage

Contains line coverage for source files in path order.

merge() combines covered and uncovered lines for each file. Covered lines take priority. Merge order and repeated inputs do not change the result.

final readonly class CoverageMap

View source

__construct()

public function __construct(array $files = [])

PHPDoc:

View source

empty()

public static function empty(): self

View source

files()

public function files(): array

PHPDoc:

View source

isEmpty()

public function isEmpty(): bool

View source

merge()

public function merge(self $other): self

View source

coveredLineTotal()

public function coveredLineTotal(): int

PHPDoc:

View source

executableLineTotal()

public function executableLineTotal(): int

PHPDoc:

View source

uncoveredLineTotal()

public function uncoveredLineTotal(): int

PHPDoc:

View source

totalPercentage()

Returns total covered lines as a percentage of executable lines.

An empty map has full coverage because it has no executable lines.

public function totalPercentage(): float

View source

FileCoverage

Namespace: Greenlight\Coverage

The class stores both sets as sorted unique lists with no common members. If a line is in both inputs, the covered input has priority. This rule makes merge() commutative, associative, and idempotent.

final readonly class FileCoverage

View source

$file

public string $file;

PHPDoc:

View source

$coveredLines

public array $coveredLines;

PHPDoc:

View source

$uncoveredLines

public array $uncoveredLines;

PHPDoc:

View source

__construct()

public function __construct(
    string $file,
    array $coveredLines,
    array $uncoveredLines,
)

PHPDoc:

View source

executableLineCount()

public function executableLineCount(): int

PHPDoc:

View source

coveredLineCount()

public function coveredLineCount(): int

PHPDoc:

View source

lineHits()

Returns executable line hit counts in ascending line order.

public function lineHits(): array

PHPDoc:

View source

percentage()

Returns covered lines as a percentage of executable lines.

A file with no executable lines has full coverage.

public function percentage(): float

View source

merge()

Merges coverage for the same file.

public function merge(self $other): self

PHPDoc:

View source