Skip to content

Commit c9d738f

Browse files
committed
feat(cryptography): allow use of Stringable DataSubjectId
1 parent 20f5f99 commit c9d738f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Cryptography/PersonalDataPayloadCryptographer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Patchlevel\Hydrator\Cryptography\Store\CipherKeyStore;
1414
use Patchlevel\Hydrator\Metadata\ClassMetadata;
1515
use Patchlevel\Hydrator\Metadata\PropertyMetadata;
16+
use Stringable;
1617

1718
use function array_key_exists;
1819
use function is_int;
@@ -143,6 +144,10 @@ private function subjectId(ClassMetadata $metadata, array $data): string|null
143144
$subjectId = (string)$subjectId;
144145
}
145146

147+
if ($subjectId instanceof Stringable) {
148+
$subjectId = $subjectId->__toString();
149+
}
150+
146151
if (!is_string($subjectId)) {
147152
throw new UnsupportedSubjectId($metadata->className(), $fieldName, $subjectId);
148153
}

0 commit comments

Comments
 (0)