src/Types/AbstractInteger.php
public function set($value)
    {
        $size = static::INTEGER_BITS;

        if (is_object($value) && $value instanceof \GMP) {
            $value = gmp_strval($value, 10);
        }

        // If the value is a string, make sure it can be converted
        // without triggering an overflow/underflow.
        // This includes values obtained from GMP objects/resources too.
        if (is_string($value) && $value === (string) (int) $value) {
            $value = (int) $value;
        }

        // base_convert() already takes care of the one's complement
        // for us when dealing with negative values.
        if (is_int($value) && strlen(base_convert($value, 10, 2)) < $size) {
            $this->value = $value;
        } else {
            // Either the value used an incompatible type,
            // was a string with an invalid value,
            // or was a string or an integer whose value
            // could not be held by the given integer size.
            throw new \InvalidArgumentException("A $size-bit signed integer was expected");
        }
    }
public function set($value)
    {
        $size = static::INTEGER_BITS;

        if (is_object($value) && $value instanceof \GMP) {
            $value = gmp_strval($value, 10);
        }

        // If the value is a string, make sure it can be converted
        // without triggering an overflow/underflow.
        // This includes values obtained from GMP objects/resources too.
        if (is_string($value) && $value === (string) (int) $value) {
            $value = (int) $value;
        }

        // base_convert() already takes care of the one's complement
        // for us when dealing with negative values.
        if (is_int($value) && strlen(base_convert($value, 10, 2)) < $size) {
            $this->value = $value;
        } else {
            // Either the value used an incompatible type,
            // was a string with an invalid value,
            // or was a string or an integer whose value
            // could not be held by the given integer size.
            throw new \InvalidArgumentException("A $size-bit signed integer was expected");
        }
    }
/ \copydoc fpoirotte::XRL::Types::AbstractType::set()