Call getFields() only once

This commit is contained in:
Ben Ramsey
2025-06-25 08:18:24 -05:00
committed by Ben Ramsey
parent 4ca249e960
commit 1fffdc32f1
+4 -6
View File
@@ -87,12 +87,10 @@ class OrderedTimeCodec extends StringCodec
$uuid = parent::decodeBytes($rearrangedBytes);
if (
/** @phpstan-ignore possiblyImpure.methodCall */
!($uuid->getFields() instanceof Rfc4122FieldsInterface)
/** @phpstan-ignore possiblyImpure.methodCall */
|| $uuid->getFields()->getVersion() !== Uuid::UUID_TYPE_TIME
) {
/** @phpstan-ignore possiblyImpure.methodCall */
$fields = $uuid->getFields();
if (!$fields instanceof Rfc4122FieldsInterface || $fields->getVersion() !== Uuid::UUID_TYPE_TIME) {
throw new UnsupportedOperationException(
'Attempting to decode a non-time-based UUID using OrderedTimeCodec',
);