Eris\Generator\FloatGenerator::shrink PHP Method

shrink() public method

public shrink ( GeneratedValue $element )
$element GeneratedValue
    public function shrink(GeneratedValue $element)
    {
        $value = $element->unbox();
        if (!$this->contains($element)) {
            throw new DomainException('Cannot shrink ' . $value . ' because it does not belong ' . 'to the domain of Floats');
        }
        if ($value < 0.0) {
            return GeneratedValue::fromJustValue(min($value + 1.0, 0.0), 'float');
        }
        if ($value > 0.0) {
            return GeneratedValue::fromJustValue(max($value - 1.0, 0.0), 'float');
        }
        return GeneratedValue::fromJustValue(0.0, 'float');
    }