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

namespace Google\Cloud\Security\PrivateCA\V1\PublicKey;

use UnexpectedValueException;

/**
 * Types of public keys formats that are supported. Currently, only `PEM`
 * format is supported.
 *
 * Protobuf type <code>google.cloud.security.privateca.v1.PublicKey.KeyFormat</code>
 */
class KeyFormat
{
    /**
     * Default unspecified value.
     *
     * Generated from protobuf enum <code>KEY_FORMAT_UNSPECIFIED = 0;</code>
     */
    const KEY_FORMAT_UNSPECIFIED = 0;
    /**
     * The key is PEM-encoded as defined in [RFC
     * 7468](https://tools.ietf.org/html/rfc7468). It can be any of the
     * following: a PEM-encoded PKCS#1/RFC 3447 RSAPublicKey
     * structure, an RFC 5280
     * [SubjectPublicKeyInfo](https://tools.ietf.org/html/rfc5280#section-4.1)
     * or a PEM-encoded X.509 certificate signing request (CSR). If a
     * [SubjectPublicKeyInfo](https://tools.ietf.org/html/rfc5280#section-4.1)
     * is specified, it can contain a A PEM-encoded PKCS#1/RFC 3447 RSAPublicKey
     * or a NIST P-256/secp256r1/prime256v1 or P-384 key. If a CSR is specified,
     * it will used solely for the purpose of extracting the public key. When
     * generated by the service, it will always be an RFC 5280
     * [SubjectPublicKeyInfo](https://tools.ietf.org/html/rfc5280#section-4.1)
     * structure containing an algorithm identifier and a key.
     *
     * Generated from protobuf enum <code>PEM = 1;</code>
     */
    const PEM = 1;

    private static $valueToName = [
        self::KEY_FORMAT_UNSPECIFIED => 'KEY_FORMAT_UNSPECIFIED',
        self::PEM => 'PEM',
    ];

    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);
    }
}


