<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/firestore/admin/v1/index.proto

namespace Google\Cloud\Firestore\Admin\V1\Index;

use UnexpectedValueException;

/**
 * Query Scope defines the scope at which a query is run. This is specified on
 * a StructuredQuery's `from` field.
 *
 * Protobuf type <code>google.firestore.admin.v1.Index.QueryScope</code>
 */
class QueryScope
{
    /**
     * The query scope is unspecified. Not a valid option.
     *
     * Generated from protobuf enum <code>QUERY_SCOPE_UNSPECIFIED = 0;</code>
     */
    const QUERY_SCOPE_UNSPECIFIED = 0;
    /**
     * Indexes with a collection query scope specified allow queries
     * against a collection that is the child of a specific document, specified
     * at query time, and that has the collection id specified by the index.
     *
     * Generated from protobuf enum <code>COLLECTION = 1;</code>
     */
    const COLLECTION = 1;
    /**
     * Indexes with a collection group query scope specified allow queries
     * against all collections that has the collection id specified by the
     * index.
     *
     * Generated from protobuf enum <code>COLLECTION_GROUP = 2;</code>
     */
    const COLLECTION_GROUP = 2;
    /**
     * Include all the collections's ancestor in the index. Only available for
     * Datastore Mode databases.
     *
     * Generated from protobuf enum <code>COLLECTION_RECURSIVE = 3;</code>
     */
    const COLLECTION_RECURSIVE = 3;

    private static $valueToName = [
        self::QUERY_SCOPE_UNSPECIFIED => 'QUERY_SCOPE_UNSPECIFIED',
        self::COLLECTION => 'COLLECTION',
        self::COLLECTION_GROUP => 'COLLECTION_GROUP',
        self::COLLECTION_RECURSIVE => 'COLLECTION_RECURSIVE',
    ];

    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(QueryScope::class, \Google\Cloud\Firestore\Admin\V1\Index_QueryScope::class);

