Skip to content

Commit 74235ab

Browse files
author
Guillaume Pédelagrabe
committed
Check if AbstractUid class exists.
1 parent 19d4558 commit 74235ab

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Serializer\Normalizer;
1313

1414
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
15+
use Symfony\Component\Serializer\Exception\LogicException;
1516
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
1617
use Symfony\Component\Uid\AbstractUid;
1718
use Symfony\Component\Uid\Ulid;
@@ -48,6 +49,10 @@ public function supportsNormalization($data, string $format = null)
4849
*/
4950
public function denormalize($data, string $type, string $format = null, array $context = [])
5051
{
52+
if (!class_exists(AbstractUid::class)) {
53+
throw new LogicException('Unable to execute this command as the Symfony Uid Component is not installed.');
54+
}
55+
5156
try {
5257
$uid = Ulid::class === $type ? Ulid::fromString($data) : Uuid::fromString($data);
5358
} catch (\InvalidArgumentException $exception) {

0 commit comments

Comments
 (0)