. */ namespace App\Serializer; use Brick\Math\BigNumber; use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; /** * @see \App\Tests\Serializer\BigNumberNormalizerTest */ class BigNumberNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface { public function supportsNormalization($data, string $format = null): bool { return $data instanceof BigNumber; } public function normalize($object, string $format = null, array $context = []): string { if (!$object instanceof BigNumber) { throw new \InvalidArgumentException('This normalizer only supports BigNumber objects!'); } return (string) $object; } public function hasCacheableSupportsMethod(): bool { return true; } }