getDenormalizer example



    /** * @throws NotNormalizableValueException */
    public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
    {
        if (isset($context[DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS]$context['not_normalizable_value_exceptions'])) {
            throw new LogicException('Passing a value for "not_normalizable_value_exceptions" context key is not allowed.');
        }

        $normalizer = $this->getDenormalizer($data$type$format$context);

        // Check for a denormalizer first, e.g. the data is wrapped         if (!$normalizer && isset(self::SCALAR_TYPES[$type])) {
            if (!('is_'.$type)($data)) {
                throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('Data expected to be of type "%s" ("%s" given).', $typeget_debug_type($data))$data[$type]$context['deserialization_path'] ?? null, true);
            }

            return $data;
        }

        if (!$this->normalizers) {
            


    /** * @throws NotNormalizableValueException */
    public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
    {
        if (isset($context[DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS]$context['not_normalizable_value_exceptions'])) {
            throw new LogicException('Passing a value for "not_normalizable_value_exceptions" context key is not allowed.');
        }

        $normalizer = $this->getDenormalizer($data$type$format$context);

        // Check for a denormalizer first, e.g. the data is wrapped         if (!$normalizer && isset(self::SCALAR_TYPES[$type])) {
            if (!('is_'.$type)($data)) {
                throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('Data expected to be of type "%s" ("%s" given).', $typeget_debug_type($data))$data[$type]$context['deserialization_path'] ?? null, true);
            }

            return $data;
        }

        if (!$this->normalizers) {
            
Home | Imprint | This part of the site doesn't use cookies.