<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/bigquery/connection/v1/connection.proto

namespace Google\Cloud\BigQuery\Connection\V1\CloudSqlProperties;

use UnexpectedValueException;

/**
 * Supported Cloud SQL database types.
 *
 * Protobuf type <code>google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType</code>
 */
class DatabaseType
{
    /**
     * Unspecified database type.
     *
     * Generated from protobuf enum <code>DATABASE_TYPE_UNSPECIFIED = 0;</code>
     */
    const DATABASE_TYPE_UNSPECIFIED = 0;
    /**
     * Cloud SQL for PostgreSQL.
     *
     * Generated from protobuf enum <code>POSTGRES = 1;</code>
     */
    const POSTGRES = 1;
    /**
     * Cloud SQL for MySQL.
     *
     * Generated from protobuf enum <code>MYSQL = 2;</code>
     */
    const MYSQL = 2;

    private static $valueToName = [
        self::DATABASE_TYPE_UNSPECIFIED => 'DATABASE_TYPE_UNSPECIFIED',
        self::POSTGRES => 'POSTGRES',
        self::MYSQL => 'MYSQL',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(DatabaseType::class, \Google\Cloud\BigQuery\Connection\V1\CloudSqlProperties_DatabaseType::class);

