public function setValueRange($minValue, $maxValue)
    {
        if (preg_match('/^([1-9][0-9]*)|([0]{1})$/', $minValue) !== 1) {
            throw new InvalidArgumentException(
                'Min value must contain only digits.'
            );
        }

        if (preg_match('/^[1-9][0-9]*$/', $maxValue) !== 1) {
            throw new InvalidArgumentException(
                'Max value must start with a nonzero digit and contain only digits.'
            );
        }

        if (gmp_cmp($maxValue, $minValue) < 1) {
            throw new InvalidArgumentException('Max value must be greater than min value.');
        }

        $this->minValue = $minValue;
        $this->maxValue = $maxValue;

        // find the minimum number of even bits to span whole set
        $this->binSize = 2;
        $span = gmp_init('4', 10);
        $multiplier = gmp_init('4', 10);
        do {
            $this->binSize += 2;
            $span = gmp_mul($span, $multiplier);
        } while (gmp_cmp($span, $this->maxValue) < 1);

        $this->decSize = strlen($this->maxValue);
        $this->hexSize = $this->binSize / 4;

        $this->sideSize = (int) $this->binSize / 2;

        if ($this->sideSize > $this->cipherLength) {
            throw new LogicException(sprintf(
                'Side size (%d bits) must be less or equal to cipher length (%d bits)',
                $this->sideSize,
                $this->cipherLength
            ));
        }

        return $this;
    }
public function setValueRange($minValue, $maxValue)
    {
        if (preg_match('/^([1-9][0-9]*)|([0]{1})$/', $minValue) !== 1) {
            throw new InvalidArgumentException(
                'Min value must contain only digits.'
            );
        }

        if (preg_match('/^[1-9][0-9]*$/', $maxValue) !== 1) {
            throw new InvalidArgumentException(
                'Max value must start with a nonzero digit and contain only digits.'
            );
        }

        if (gmp_cmp($maxValue, $minValue) < 1) {
            throw new InvalidArgumentException('Max value must be greater than min value.');
        }

        $this->minValue = $minValue;
        $this->maxValue = $maxValue;

        // find the minimum number of even bits to span whole set
        $this->binSize = 2;
        $span = gmp_init('4', 10);
        $multiplier = gmp_init('4', 10);
        do {
            $this->binSize += 2;
            $span = gmp_mul($span, $multiplier);
        } while (gmp_cmp($span, $this->maxValue) < 1);

        $this->decSize = strlen($this->maxValue);
        $this->hexSize = $this->binSize / 4;

        $this->sideSize = (int) $this->binSize / 2;

        if ($this->sideSize > $this->cipherLength) {
            throw new LogicException(sprintf(
                'Side size (%d bits) must be less or equal to cipher length (%d bits)',
                $this->sideSize,
                $this->cipherLength
            ));
        }

        return $this;
    }
public function setValueRange ( $ minValue , $ maxValue ) { if ( preg_match ( '/^([1-9][0-9]*)|([0]{1})$/' , $ minValue ) !== 1 ) { throw new InvalidArgumentException ( 'Min value must contain only digits.' ) ; } if ( preg_match ( '/^[1-9][0-9]*$/' , $ maxValue ) !== 1 ) { throw new InvalidArgumentException ( 'Max value must start with a nonzero digit and contain only digits.' ) ; } if ( gmp_cmp ( $ maxValue , $ minValue ) < 1 ) { throw new InvalidArgumentException ( 'Max value must be greater than min value.' ) ; } $ this -> minValue = $ minValue ; $ this -> maxValue = $ maxValue ; // find the minimum number of even bits to span whole set $ this -> binSize = 2 ; $ span = gmp_init ( '4' , 10 ) ; $ multiplier = gmp_init ( '4' , 10 ) ; do { $ this -> binSize += 2 ; $ span = gmp_mul ( $ span , $ multiplier ) ; } while ( gmp_cmp ( $ span , $ this -> maxValue ) < 1 ) ; $ this -> decSize = strlen ( $ this -> maxValue ) ; $ this -> hexSize = $ this -> binSize / 4 ; $ this -> sideSize = ( int ) $ this -> binSize / 2 ; if ( $ this -> sideSize > $ this -> cipherLength ) { throw new LogicException ( sprintf ( 'Side size (%d bits) must be less or equal to cipher length (%d bits)' , $ this -> sideSize , $ this -> cipherLength ) ) ; } return $ this ; }
Set value range and pad sizes.

@param string $minValue Minimum value. String representation of positive integer value or zero.
@param string $maxValue Maximum value. String representation of positive integer value.

@throws InvalidArgumentException If provided invalid parameters.

@return Cryptomute
Set value range and pad sizes .