Skip to content

CharsetStringArbitrary ​

Rasuvaeff\PropertyTesting\Arbitrary\CharsetStringArbitrary

Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2

Implements: ArbitraryInterface

Generates strings whose characters come from a fixed alphabet, and shrinks them by length toward the empty string, then character-by-character toward the first alphabet character (list simpler characters first).

The alphabet is split per Unicode codepoint, so multibyte alphabets work; duplicate characters are collapsed. Length is chosen uniformly within an inclusive range.

Constructor ​

php
__construct(
    string $alphabet,
    int $minLength = 0,
    int $maxLength = 100,
)
ParameterTypeDefaultDescription
$alphabetstringrequired
$minLengthint0
$maxLengthint100

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.