diff --git a/src/GPBMetadata/Ratelimit/Ratelimit.php b/src/GPBMetadata/Ratelimit/Ratelimit.php index a7afc10..1007691 100644 --- a/src/GPBMetadata/Ratelimit/Ratelimit.php +++ b/src/GPBMetadata/Ratelimit/Ratelimit.php @@ -47,7 +47,7 @@ public static function initOnce() { "696d6974526571756573741a242e70622e6c7966742e726174656c696d69" . "742e526174654c696d6974526573706f6e73652200420e5a09726174656c" . "696d6974800101620670726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/src/Pb/Lyft/Ratelimit/RateLimit.php b/src/Pb/Lyft/Ratelimit/RateLimit.php index 1fdb98a..dd5437e 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimit.php +++ b/src/Pb/Lyft/Ratelimit/RateLimit.php @@ -7,6 +7,7 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\GPBWrapperUtils; /** * Defines an actual rate limit in terms of requests per unit of time and the unit itself. diff --git a/src/Pb/Lyft/Ratelimit/RateLimit/Unit.php b/src/Pb/Lyft/Ratelimit/RateLimit/Unit.php index 7d003cd..a386192 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimit/Unit.php +++ b/src/Pb/Lyft/Ratelimit/RateLimit/Unit.php @@ -4,6 +4,8 @@ namespace Pb\Lyft\Ratelimit\RateLimit; +use UnexpectedValueException; + /** * Protobuf type pb.lyft.ratelimit.RateLimit.Unit */ @@ -29,6 +31,34 @@ class Unit * Generated from protobuf enum DAY = 4; */ const DAY = 4; + + private static $valueToName = [ + self::UNKNOWN => 'UNKNOWN', + self::SECOND => 'SECOND', + self::MINUTE => 'MINUTE', + self::HOUR => 'HOUR', + self::DAY => 'DAY', + ]; + + 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. diff --git a/src/Pb/Lyft/Ratelimit/RateLimitDescriptor.php b/src/Pb/Lyft/Ratelimit/RateLimitDescriptor.php index 3a1080e..3ff18d9 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimitDescriptor.php +++ b/src/Pb/Lyft/Ratelimit/RateLimitDescriptor.php @@ -7,6 +7,7 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\GPBWrapperUtils; /** * A RateLimitDescriptor is a list of hierarchical entries that are used by the service to diff --git a/src/Pb/Lyft/Ratelimit/RateLimitDescriptor/Entry.php b/src/Pb/Lyft/Ratelimit/RateLimitDescriptor/Entry.php index 344cb62..ca41c7a 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimitDescriptor/Entry.php +++ b/src/Pb/Lyft/Ratelimit/RateLimitDescriptor/Entry.php @@ -7,6 +7,7 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\GPBWrapperUtils; /** * Generated from protobuf message pb.lyft.ratelimit.RateLimitDescriptor.Entry diff --git a/src/Pb/Lyft/Ratelimit/RateLimitRequest.php b/src/Pb/Lyft/Ratelimit/RateLimitRequest.php index c5d85f9..215f8db 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimitRequest.php +++ b/src/Pb/Lyft/Ratelimit/RateLimitRequest.php @@ -7,6 +7,7 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\GPBWrapperUtils; /** * Main message for a rate limit request. The rate limit service is designed to be fully generic diff --git a/src/Pb/Lyft/Ratelimit/RateLimitResponse.php b/src/Pb/Lyft/Ratelimit/RateLimitResponse.php index 3771da7..2b89b16 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimitResponse.php +++ b/src/Pb/Lyft/Ratelimit/RateLimitResponse.php @@ -7,6 +7,7 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\GPBWrapperUtils; /** * A response from a ShouldRateLimit call. diff --git a/src/Pb/Lyft/Ratelimit/RateLimitResponse/Code.php b/src/Pb/Lyft/Ratelimit/RateLimitResponse/Code.php index 251dc17..e2c3546 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimitResponse/Code.php +++ b/src/Pb/Lyft/Ratelimit/RateLimitResponse/Code.php @@ -4,6 +4,8 @@ namespace Pb\Lyft\Ratelimit\RateLimitResponse; +use UnexpectedValueException; + /** * Protobuf type pb.lyft.ratelimit.RateLimitResponse.Code */ @@ -21,6 +23,32 @@ class Code * Generated from protobuf enum OVER_LIMIT = 2; */ const OVER_LIMIT = 2; + + private static $valueToName = [ + self::UNKNOWN => 'UNKNOWN', + self::OK => 'OK', + self::OVER_LIMIT => 'OVER_LIMIT', + ]; + + 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. diff --git a/src/Pb/Lyft/Ratelimit/RateLimitResponse/DescriptorStatus.php b/src/Pb/Lyft/Ratelimit/RateLimitResponse/DescriptorStatus.php index 234a8c8..ba58772 100644 --- a/src/Pb/Lyft/Ratelimit/RateLimitResponse/DescriptorStatus.php +++ b/src/Pb/Lyft/Ratelimit/RateLimitResponse/DescriptorStatus.php @@ -7,6 +7,7 @@ use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; +use Google\Protobuf\Internal\GPBWrapperUtils; /** * Generated from protobuf message pb.lyft.ratelimit.RateLimitResponse.DescriptorStatus