public static function serializeValue($type, $value)
    {
        switch ($type) {
        case null:
            return $value;

        case EdmType::INT32:
            return intval($value);

        case EdmType::INT64:
        case EdmType::GUID:
        case EdmType::STRING:
            return strval($value);

        case EdmType::DOUBLE:
            return strval($value);

        case EdmType::BINARY:
            return base64_encode($value);

        case EdmType::DATETIME:
            return Utilities::convertToEdmDateTime($value);

        case EdmType::BOOLEAN:
            return (is_null($value) ? '' : ($value == true ? true : false));

        default:
            throw new \InvalidArgumentException();
        }
    }