protected function validateType(&$value, $type, $coerce = false)
    {
        //mostly the case for inline schema
        if (!$type) {
            return true;
        }

        if ('any' === $type) {
            return true;
        }

        if ('object' === $type) {
            return $this->getTypeCheck()->isObject($value);
        }

        if ('array' === $type) {
            if ($coerce) {
                $value = $this->toArray($value);
            }

            return $this->getTypeCheck()->isArray($value);
        }

        if ('integer' === $type) {
            if ($coerce) {
                $value = $this->toInteger($value);
            }

            return is_int($value);
        }

        if ('number' === $type) {
            if ($coerce) {
                $value = $this->toNumber($value);
            }

            return is_numeric($value) && !is_string($value);
        }

        if ('boolean' === $type) {
            if ($coerce) {
                $value = $this->toBoolean($value);
            }

            return is_bool($value);
        }

        if ('string' === $type) {
            if ($coerce) {
                $value = $this->toString($value);
            }

            return is_string($value);
        }

        if ('null' === $type) {
            if ($coerce) {
                $value = $this->toNull($value);
            }

            return is_null($value);
        }

        throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
    }
protected function validateType(&$value, $type, $coerce = false)
    {
        //mostly the case for inline schema
        if (!$type) {
            return true;
        }

        if ('any' === $type) {
            return true;
        }

        if ('object' === $type) {
            return $this->getTypeCheck()->isObject($value);
        }

        if ('array' === $type) {
            if ($coerce) {
                $value = $this->toArray($value);
            }

            return $this->getTypeCheck()->isArray($value);
        }

        if ('integer' === $type) {
            if ($coerce) {
                $value = $this->toInteger($value);
            }

            return is_int($value);
        }

        if ('number' === $type) {
            if ($coerce) {
                $value = $this->toNumber($value);
            }

            return is_numeric($value) && !is_string($value);
        }

        if ('boolean' === $type) {
            if ($coerce) {
                $value = $this->toBoolean($value);
            }

            return is_bool($value);
        }

        if ('string' === $type) {
            if ($coerce) {
                $value = $this->toString($value);
            }

            return is_string($value);
        }

        if ('null' === $type) {
            if ($coerce) {
                $value = $this->toNull($value);
            }

            return is_null($value);
        }

        throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
    }
protected function validateType ( & $ value , $ type , $ coerce = false ) { //mostly the case for inline schema if ( ! $ type ) { return true ; } if ( 'any' === $ type ) { return true ; } if ( 'object' === $ type ) { return $ this -> getTypeCheck ( ) -> isObject ( $ value ) ; } if ( 'array' === $ type ) { if ( $ coerce ) { $ value = $ this -> toArray ( $ value ) ; } return $ this -> getTypeCheck ( ) -> isArray ( $ value ) ; } if ( 'integer' === $ type ) { if ( $ coerce ) { $ value = $ this -> toInteger ( $ value ) ; } return is_int ( $ value ) ; } if ( 'number' === $ type ) { if ( $ coerce ) { $ value = $ this -> toNumber ( $ value ) ; } return is_numeric ( $ value ) && ! is_string ( $ value ) ; } if ( 'boolean' === $ type ) { if ( $ coerce ) { $ value = $ this -> toBoolean ( $ value ) ; } return is_bool ( $ value ) ; } if ( 'string' === $ type ) { if ( $ coerce ) { $ value = $ this -> toString ( $ value ) ; } return is_string ( $ value ) ; } if ( 'null' === $ type ) { if ( $ coerce ) { $ value = $ this -> toNull ( $ value ) ; } return is_null ( $ value ) ; } throw new InvalidArgumentException ( ( is_object ( $ value ) ? 'object' : $ value ) . ' is an invalid type for ' . $ type ) ; }
Verifies that a given value is of a certain type

@param mixed  $value Value to validate
@param string $type  TypeConstraint to check against

@throws InvalidArgumentException

@return bool
Verifies that a given value is of a certain type