Skip to content

ConstantArbitrary

Rasuvaeff\PropertyTesting\Arbitrary\ConstantArbitrary

ClassPackage: property-testing-coreSourceVersion: v0.1.0-12-g86ead85

Implements: ArbitraryInterface

Type parameters:

  • TValue of mixed = mixed

Always produces the same fixed value. Useful as a building block for composite generators (e.g. a record field that is held constant) and for pinning one parameter while others vary.

There is nothing smaller than a constant, so it does not shrink.

Constructor

php
__construct(
    \Arbitrary\TValue $value,
)
ParameterTypeDefaultDescription
$valueArbitrary\TValuerequired

Methods

generate()

php
generate(Random $random): Shrinkable

Produce one random value from this arbitrary's space, together with its shrink tree. Candidates must be ordered most aggressive first (typically toward a zero/empty/identity element) and every branch of the tree must be finite, so shrinking terminates.

Documentation inherited from ArbitraryInterface.