Skip to content

Commit a4e9d30

Browse files
committed
Add guard check to be consistent with other normalizers
1 parent 642fcc0 commit a4e9d30

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Serializer\Normalizer;
1313

14+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
1415
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
1516
use Symfony\Component\Uid\AbstractUid;
1617
use Symfony\Component\Uid\Ulid;
@@ -23,6 +24,10 @@ final class UidNormalizer implements NormalizerInterface, DenormalizerInterface,
2324
*/
2425
public function normalize($object, string $format = null, array $context = [])
2526
{
27+
if (!$object instanceof AbstractUid) {
28+
throw new InvalidArgumentException('The object must be an instance of "Symfony\Component\Uid\AbstractUid".');
29+
}
30+
2631
return (string) $object;
2732
}
2833

0 commit comments

Comments
 (0)