Skip to content

StubbedEnvironmentReader

The isolated-replay counterpart to RecordingEnvironmentReader: never reads a real environment variable, answering every call from an injected EffectLedger matched on the bare variable name.

A variable with no matching recorded effect throws rather than fabricating a value or falling through to the real getenv() — inventing a value would fabricate a passing test, the same rule StubbedCache/StubbedPdo/StubbedHttpTransport follow. A variable that WAS recorded as unset (false) replays as false, not an exception — that is itself the recorded, correct answer.

final class StubbedEnvironmentReader implements EnvironmentReaderInterface

ImplementsEnvironmentReaderInterface
SourceReplay/StubbedEnvironmentReader.php

public function __construct(EffectLedger $ledger): mixed

ParameterTypeDescription
$ledgerEffectLedger

Returns mixed

MethodDescription
[`get(string $name): stringfalse`](#get)

public function get(string $name): string|false

The value of environment variable $name, or false when it is unset.

ParameterTypeDescription
$namestring

Returns string``|``false