function SnakeCaseToCamelCaseNameConverter::denormalize
Parameters
class-string|null $class:
array<string, mixed> $context:
Overrides NameConverterInterface::denormalize
File
-
vendor/
symfony/ serializer/ NameConverter/ SnakeCaseToCamelCaseNameConverter.php, line 65
Class
- SnakeCaseToCamelCaseNameConverter
- Underscore to camelCase name converter.
Namespace
Symfony\Component\Serializer\NameConverterCode
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []) : string {
if (($context[self::REQUIRE_CAMEL_CASE_PROPERTIES] ?? false) && $propertyName !== $this->normalize($propertyName, $class, $format, $context)) {
throw new UnexpectedPropertyException($propertyName);
}
$snakeCased = strtolower(preg_replace('/[A-Z]/', '_\\0', lcfirst($propertyName)));
if (null === $this->attributes || \in_array($snakeCased, $this->attributes, true)) {
return $snakeCased;
}
return $propertyName;
}