Converts an integer value to an enum of this type
@param int $int
@return \static
@throws \InvalidArgumentException
773853
public static function fromInt($int){
		
		if(!\is_int($int)){
			throw new \InvalidArgumentException('$int must be an integer');
		}
		
		$flags = new static();
		
		foreach(static::getEnumValues() as $const){			
			if(($int & $const) === $const){
				$flags->addFlag($const);
			}
		}

		return $flags;
		
	}
363950
public function toInt()
    {
        if (is_array($this->value)) {
            throw new InvalidNotArrayException($this->name);
        } elseif (!empty($this->value) && !is_numeric($this->value)) {
            throw new InvalidNumericException($this->name, $this->value);
        }

        $this->value = (int) $this->value;

        return $this;
    }
1203732
public static function fromInteger(int $int, ?int $minLength = null)
    {
        $pieces = str_split(decbin($int), 8);
        $num = count($pieces);

        if ($num === 1 && strlen($pieces[0]) !== 8) {
            $pieces[0] = str_pad($pieces[0], 8, '0', STR_PAD_LEFT);
        } elseif ($num > 0 && strlen($pieces[$num - 1]) !== 8) {
            $pieces[$num - 1] = str_pad($pieces[$num - 1], 8, '0', STR_PAD_RIGHT);
        }

        $bitstring = implode('', $pieces);
        if ($minLength && strlen($bitstring) < $minLength) {
            $bitstring = str_pad($bitstring, $minLength, '0');
        }

        return new self($bitstring);
    }
629874
public static function limitInteger($int, $min = null, $max = null)
    {
        $int = (int) $int;

        if ($min !== null && $int < $min) {
            $int = $min;
        }

        if ($max !== null && $int > $max) {
            $int = $max;
        }

        return (int) $int;
    }
797183
public static function isInt($int)
    {
        return (is_string($int) || is_int($int) || is_float($int)) &&
            ctype_digit((string)$int);
    }
833813
public static function ToInteger( $value, $provider = null )
	{
	     $int = $value + 0;
	     if ( is_null( $int ) ) throw new InvalidCastException("Unable to convert value '$value' to type Integer" );

	     return Long::FromValue( $int );
	}
692276
public static function intBytes($int)
    {
        $intbytes = "";

        if ($int > 0xFFFF) {
            $intbytes = "\x12".pack("N", $int); // 4 byte integer
        } elseif ($int > 0xFF) {
            $intbytes = "\x11".pack("n", $int); // 2 byte integer
        } else {
            $intbytes = "\x10".pack("C", $int); // 8 byte integer
        }

        return $intbytes;
    }
883522
private function int4Type6($Int)
    {
        if ($Int === 1) {
            return 0;
        }
        $Tail2 = $Int % 100;
        if ($Tail2 > 10 && $Tail2 < 20) {
            return 2;
        }
        if ($Int === 0 || ($Tail2 > 1 && $Tail2 < 11)) {
            return 3;
        }
        return 1;
    }
720957
public function toBase($base)
    {
        if ($this->normalize()->hasDecimals()) {
            throw new \InvalidArgumentException('Argument number is not an integer');
        }

        // do not mutate, only support positive integers
        $number = ltrim((string) $this, '-');
        if (static::$gmpSupport && $base <= 62) {
            return static::baseConvert($number, 10, $base);
        }

        $result   = '';
        $baseChar = static::getBaseChar($base);
        while (bccomp($number, 0) != 0) { // still data to process
            $rem    = bcmod($number, $base); // calc the remainder
            $number = bcdiv(bcsub($number, $rem), $base);
            $result = $baseChar[$rem] . $result;
        }

        $result = $result ? $result : $baseChar[0];

        return (string) $result;
    }
944451
public function setIndex($index)
    {
        if (!is_int($index) || $index < 0) {
            throw new \InvalidArgumentException(sprintf('The value\'s index must be a positive integer, "%s" given', var_export($index, true)));
        }
        $this->index = $index;
        return $this;
    }
196194
protected function IDiv( $val )
	{
		if ( ! $val instanceof IntProxy ) throw new \InvalidArgumentException();

		/**
		 * @var DecimalValue $result
		 */
		$result = $this->Div( $val );
		return Integer::FromValue( $result->getValue()->getIntegerPart() );
	}
874726
public function writeInteger($int)
    {
        try {
            $this->getStream()->write(pack('l', $int));
        } catch (StreamException $e) {
            $this->handleStreamException($e, BinaryStreamAccessException::INT, false);
        }
    }
335068
protected function _validateEnumValue($arg)
	{
		parent::_validateEnumValue($arg);
		$enum = strtoupper(trim($arg));
		if($enum !== 'ASC' && $enum !== 'DESC')
		{
			throw new \InvalidArgumentException('argument has to be a string of asc or desc!');
		}
		$this->enum = $enum;
	}
103635
public static function enum($value, $options){

		$value = static::_nullValue($value);

		if(!in_array($value, $options)){

			return null;
		}

		return $value;
	}
655559
public function divide($number)
    {
        self::mustBeNumeric($number, 'Value to divide');
        
        $number = is_object($number) ? $number->value : $number;
        
        if ($number == 0) {
            throw new \InvalidArgumentException('You cannot divide by zero!');
        }

        return new self($this->value / $number);
    }
71482
public function setType($type = null)
    {
        $type = $this->calculateTypeValue($type);

        if (!is_int($type) || ($type < 0) || ($type > self::ALL)) {
            throw new Exception\InvalidArgumentException('Unknown type');
        }

        $this->options['type'] = $type;

        return $this;
    }
1003687
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (null === $value) {
            return null;
        }

        if (!isset(static::$choices[$value])) {
            throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM "%s".', $value, $this->getName()));
        }

        return $value;
    }