Skip to content

Commit 95da9ee

Browse files
valtzumtarld
andauthored
Apply suggestions from code review
Co-authored-by: Mathias Arlaud <mathias.arlaud@gmail.com>
1 parent 7d4a688 commit 95da9ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getSupportedTypes(?string $format): array
3030
public function normalize(mixed $data, ?string $format = null, array $context = []): string
3131
{
3232
if (!$data instanceof Number) {
33-
throw new InvalidArgumentException('The data must be an instance of '.Number::class.'.');
33+
throw new InvalidArgumentException(\sprintf('The data must be an instance of "%s".', Number::class);
3434
}
3535

3636
return (string) $data;
@@ -47,17 +47,17 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
4747
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): Number
4848
{
4949
if (Number::class !== $type) {
50-
throw new InvalidArgumentException('Only '.Number::class.' supported.');
50+
throw new InvalidArgumentException(\sprintf('Only "%s" type is supported.', Number::class);
5151
}
5252

5353
if (!\is_int($data) && !\is_string($data)) {
54-
throw NotNormalizableValueException::createForUnexpectedDataType('The data is neither an integer nor a string, you should pass an integer or a string that represents a decimal number.', $data, ['int', 'string'], $context['deserialization_path'] ?? null, true);
54+
throw NotNormalizableValueException::createForUnexpectedDataType('The data is neither an "int" nor a "string", you should pass an "int" or a "string" that represents a decimal number.', $data, ['int', 'string'], $context['deserialization_path'] ?? null, true);
5555
}
5656

5757
try {
5858
return new Number($data);
5959
} catch (\ValueError $e) {
60-
throw NotNormalizableValueException::createForUnexpectedDataType('The data must represent a decimal number', $data, [$type], $context['deserialization_path'] ?? null, true, 0, $e);
60+
throw NotNormalizableValueException::createForUnexpectedDataType('The data must represent a decimal number', $data, ['int', 'string'], $context['deserialization_path'] ?? null, true, 0, $e);
6161
}
6262
}
6363

0 commit comments

Comments
 (0)