src/Api/TypeCatalog.php
public function validate(string $type, $value): bool
    {
        switch ($type) {
            case self::TYPE_NULL:
                return is_null($value);
            case self::TYPE_BOOLEAN:
                return is_bool($value);
            case self::TYPE_INTEGER:
                return is_integer($value);
            case self::TYPE_FLOAT:
                return is_float($value);
            case self::TYPE_STRING:
                return is_string($value);
            case self::TYPE_ARRAY:
                if (!is_array($value)) {
                    return false;
                }
                return $this->isArrayType($value);
            case self::TYPE_OBJECT:
                if (!is_array($value)) {
                    return false;
                }
                return $this->isObjectType($value);
            case self::TYPE_BINARY:
                return is_string($value);
        }

        throw new InvalidValueException("Invalid value type: $type");
    }
public function validate(string $type, $value): bool
    {
        switch ($type) {
            case self::TYPE_NULL:
                return is_null($value);
            case self::TYPE_BOOLEAN:
                return is_bool($value);
            case self::TYPE_INTEGER:
                return is_integer($value);
            case self::TYPE_FLOAT:
                return is_float($value);
            case self::TYPE_STRING:
                return is_string($value);
            case self::TYPE_ARRAY:
                if (!is_array($value)) {
                    return false;
                }
                return $this->isArrayType($value);
            case self::TYPE_OBJECT:
                if (!is_array($value)) {
                    return false;
                }
                return $this->isObjectType($value);
            case self::TYPE_BINARY:
                return is_string($value);
        }

        throw new InvalidValueException("Invalid value type: $type");
    }
public function validate ( string $ type , $ value ) : bool { switch ( $ type ) { case self :: TYPE_NULL : return is_null ( $ value ) ; case self :: TYPE_BOOLEAN : return is_bool ( $ value ) ; case self :: TYPE_INTEGER : return is_integer ( $ value ) ; case self :: TYPE_FLOAT : return is_float ( $ value ) ; case self :: TYPE_STRING : return is_string ( $ value ) ; case self :: TYPE_ARRAY : if ( ! is_array ( $ value ) ) { return false ; } return $ this -> isArrayType ( $ value ) ; case self :: TYPE_OBJECT : if ( ! is_array ( $ value ) ) { return false ; } return $ this -> isObjectType ( $ value ) ; case self :: TYPE_BINARY : return is_string ( $ value ) ; } throw new InvalidValueException ( "Invalid value type: $type" ) ; }
Validates a value against a type.

@param mixed $value
@param string $type
@return bool
@throws InvalidValueException
Validates a value against a type .