Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SnakeCaseToCamelCaseNameConverter.php

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\NameConverter

Code

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;
}
RSS feed
Powered by Drupal