src/IntType.php
protected function check($value)
    {
        if (is_int($value)) {
            return $value;
        }

        if ($value === false || $value === 0.0 || $value === '0') {
            return 0;
        }

        if ($value === true || $value === 1.0 || $value === '1') {
            return 1;
        }

        if ($value instanceof IntType) {
            return $value->value();
        }

        if ($value instanceof Type) {
            $value = $value->value();
        } else {
            if (is_array($value)) {
                throw new InvalidArgumentException('Invalid int, array given');
            }

            if (is_resource($value)) {
                throw new InvalidArgumentException('Invalid int, resource given');
            }

            if (is_object($value)) {
                throw new InvalidArgumentException('Invalid int, object given');
            }
        }

        try {
            $value = parent::check($value);
        } catch (InvalidArgumentException $e) {
            throw new InvalidArgumentException('Invalid int: ' . $value);
        }

        if (filter_var($value, FILTER_VALIDATE_INT) === false) {
            throw new InvalidArgumentException('Invalid int: ' . $value);
        }

        return (int) $value;
    }
protected function check($value)
    {
        if (is_int($value)) {
            return $value;
        }

        if ($value === false || $value === 0.0 || $value === '0') {
            return 0;
        }

        if ($value === true || $value === 1.0 || $value === '1') {
            return 1;
        }

        if ($value instanceof IntType) {
            return $value->value();
        }

        if ($value instanceof Type) {
            $value = $value->value();
        } else {
            if (is_array($value)) {
                throw new InvalidArgumentException('Invalid int, array given');
            }

            if (is_resource($value)) {
                throw new InvalidArgumentException('Invalid int, resource given');
            }

            if (is_object($value)) {
                throw new InvalidArgumentException('Invalid int, object given');
            }
        }

        try {
            $value = parent::check($value);
        } catch (InvalidArgumentException $e) {
            throw new InvalidArgumentException('Invalid int: ' . $value);
        }

        if (filter_var($value, FILTER_VALIDATE_INT) === false) {
            throw new InvalidArgumentException('Invalid int: ' . $value);
        }

        return (int) $value;
    }
protected function check ( $ value ) { if ( is_int ( $ value ) ) { return $ value ; } if ( $ value === false || $ value === 0.0 || $ value === '0' ) { return 0 ; } if ( $ value === true || $ value === 1.0 || $ value === '1' ) { return 1 ; } if ( $ value instanceof IntType ) { return $ value -> value ( ) ; } if ( $ value instanceof Type ) { $ value = $ value -> value ( ) ; } else { if ( is_array ( $ value ) ) { throw new InvalidArgumentException ( 'Invalid int, array given' ) ; } if ( is_resource ( $ value ) ) { throw new InvalidArgumentException ( 'Invalid int, resource given' ) ; } if ( is_object ( $ value ) ) { throw new InvalidArgumentException ( 'Invalid int, object given' ) ; } } try { $ value = parent :: check ( $ value ) ; } catch ( InvalidArgumentException $ e ) { throw new InvalidArgumentException ( 'Invalid int: ' . $ value ) ; } if ( filter_var ( $ value , FILTER_VALIDATE_INT ) === false ) { throw new InvalidArgumentException ( 'Invalid int: ' . $ value ) ; } return ( int ) $ value ; }
Check the value

@param  mixed $value
@return int
Check the value