@param mixed  $data
@param string $class
@param string $name
@param string $format
@param array  $context

@throws RuntimeException

@return mixed|object
183162
protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array())
    {
        if (!$this->propertyInfoExtractor) {
            return $data;
        }

        /** @var Type[] $types */
        $types = (array) $this->propertyInfoExtractor->getTypes($class, $name);
        $_class = null;
        $_class = array_reduce(
            $types,
            function($class, Type $type) {
                return $class ?: $type->getClassName();
            },
            $_class
        );

        if ($data === null and $_class === null) {
            return $data;
        }

        if (!$this->serializer instanceof DenormalizerInterface) {
            $message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer';
            throw new RuntimeException(sprintf($message, $name));
        }

        if ($_class === null
            or !$this->serializer->supportsDenormalization($data, $_class, $format, $context)) {
            return $data;
        }

        return $this->serializer->denormalize($data, $_class, $format, $context);
    }
535231
public function get(array $data, $className, callable $callable)
    {
        try {
            DataObject::assertPost($data, $this->serializer, $className, $this->errorBag);

            $values = DataObject::getAttributes($data, $this->serializer);
            $model = $callable($data, $values, $this->errorBag);

            $response = $this->resourceCreated($this->serializer->serialize($model));
        } catch (Exception $e) {
            $response = $this->getErrorResponse($e, $this->errorBag);
        }

        return $response;
    }
574909
protected function applyFormat($format, $data)
    {

        foreach ($format as $key => $value) {
            $meta = array_values(array_filter($this->formatting, function ($item) use ($value) {
                return $item['name'] === $value['function'] ? true : false;
            }));

            if ($meta && !array_key_exists('class', $value)) {
                $data = $this->applyDefaultFormat($value, $meta[0], $data);
            } else {
                $data = $this->applyCustomFormat($value, $data);
            }
        }

        return $data;
    }
1310039
public function resolve($name, $format, array $data, $method = 'compose')
    {
        $parser = $this->parse($name);
        $format = $format ?? $this->getPrefersFor($parser);

        return $parser->compose($format, $data, $method);
    }
70393
public function encode($data, $format, array $context = [])
    {
        return $this->yamlEncode->encode($data, $format, $context);
    }
446106
public function denormalize($data, $class, $format = null, array $context = array())
    {
        /** @var \ReflectionParameter[] $params */
        $params = $context['params'];
        $indexBy = isset($context['indexBy']) ? $context['indexBy'] : 'name';

        $arguments = [];
        foreach ($params as $param) {
            $index = $param->getPosition();

            $arguments[$index] = $this->denormalizeParam($data, $param, $format, $context);
        }
        ksort($arguments);

        $output = [];
        foreach ($params as $param) {
            $name = $param->getName();
            $index = $param->getPosition();
            $key = $indexBy === 'name' ? $name : $index;

            $output[$key] = $arguments[$index];
        }

        return $output;
    }
649301
public function format($name, array $data)
    {
        if (!isset($this->_compiled[$name])) {
            throw new RuntimeException("Cannot find template named '$name'.");
        }
        list($template, $placeholders) = $this->_compiled[$name];

        if (isset($data['templateVars'])) {
            $data += $data['templateVars'];
            unset($data['templateVars']);
        }
        $replace = [];
        foreach ($placeholders as $placeholder) {
            $replacement = isset($data[$placeholder]) ? $data[$placeholder] : null;
            if (is_array($replacement)) {
                $replacement = implode('', $replacement);
            }
            $replace[] = $replacement;
        }

        return vsprintf($template, $replace);
    }
487663
public function denormalize($data, $class, $format = null, array $context = [])
    {
        // Handle -1 in expiresAt property of AppCredential.
        if ($data < 0) {
            return null;
        }
        $context[$this->normalizer::FORMAT_KEY] = 'U';
        $context[$this->normalizer::TIMEZONE_KEY] = new \DateTimeZone('UTC');

        return $this->normalizer->denormalize(intval($data / 1000), $class, $format, $context);
    }
883002
public function makeData(Data $data): ?DataObjectFormat
    {
        if (!$data->isInstanceOf(Data::class)) {
            return null;
        }

        return DataObjectFormat::make($data);
    }
196824
public function format($name, array $data) {
        $name = $this->_getTemplateName($name, $data);
        return parent::format($name, $data);
    }
194413
private function getDecoder(string $format, array $context): DecoderInterface
    {
        if (isset($this->decoderByFormat[$format])
            && isset($this->decoders[$this->decoderByFormat[$format]])
        ) {
            return $this->decoders[$this->decoderByFormat[$format]];
        }

        foreach ($this->decoders as $i => $decoder) {
            if ($decoder->supportsDecoding($format, $context)) {
                $this->decoderByFormat[$format] = $i;

                return $decoder;
            }
        }

        throw new RuntimeException(sprintf('No decoder found for format "%s".', $format));
    }
843099
public function denormalize($data, $class, $format = null, array $context = [])
    {
        // Avoid issues with proxies if we populated the object
        if (isset($data['id']) && !isset($context[self::OBJECT_TO_POPULATE])) {
            if (isset($context['api_allow_update']) && true !== $context['api_allow_update']) {
                throw new NotNormalizableValueException('Update is not allowed for this operation.');
            }

            if (isset($context['resource_class'])) {
                $this->updateObjectToPopulate($data, $context);
            } else {
                // See https://github.com/api-platform/core/pull/2326 to understand this message.
                $this->logger->warning('The "resource_class" key is missing from the context.', [
                    'context' => $context,
                ]);
            }
        }

        return parent::denormalize($data, $class, $format, $context);
    }
175888
public function renderTemplate($path, array $data = [], $class = null)
    {
        if (file_exists($path)) {
            return $this->doRender($path, $data, $class);
        }
        throw new RuntimeException(__METHOD__.' needs a valid template path as first argument.');
    }
944734
public function validate($name, $data, $format = null)
    {
        if (!is_numeric($data) || !is_float(floatval($data))) {
            throw new Exception("propriedade [ {$name} ] é inválida para tipo [ float ] definido no schema", 400);
        }

        if ($format) {
            $data = self::applyFormat($format, $data);
        }

        return floatval($data);
    }
462079
private function updateData(array $data, string $attribute, $attributeValue, string $class, ?string $format, array $context): array
    {
        if (null === $attributeValue && ($context[self::SKIP_NULL_VALUES] ?? $this->defaultContext[self::SKIP_NULL_VALUES] ?? false)) {
            return $data;
        }

        if ($this->nameConverter) {
            $attribute = $this->nameConverter->normalize($attribute, $class, $format, $context);
        }

        $data[$attribute] = $attributeValue;

        return $data;
    }
233874
public function normalize($data, $format = null, array $context = [])
    {
        if ($data instanceof ResourceInterface) {
            $event = new BeforeNormalizationEvent($data, (string) $format, $context);
            $this->eventDispatcher->dispatch(SerializationEvents::BEFORE_NORMALIZATION, $event);
        }

        $countNormalizers = 0;

        if (array_key_exists('normalizers', $context)) {
            $countNormalizers = count($context['normalizers']);
            /** @var NormalizerInterface[] $normalizers */
            $normalizers = array_reverse($context['normalizers']);

            foreach ($normalizers as $normalizer) {
                $this->prepareNormalizer($normalizer);
                array_unshift($this->normalizers, $normalizer);
            }
        }

        try {
            $normalized = parent::normalize($data, $format, $context);
        } finally {
            for ($i = 0; $i < $countNormalizers; $i++) {
                array_shift($this->normalizers);
            }
        }

        if ($data instanceof ResourceInterface) {
            $event = new AfterNormalizationEvent($data, $normalized, (string) $format, $context);
            $this->eventDispatcher->dispatch(SerializationEvents::AFTER_NORMALIZATION, $event);
        }

        return $normalized;
    }
1068427
private function parseContext($name, array $input, $default = [])
    {
        if (isset($input[$name])) {
            if (!is_array($input[$name])) {
                throw new Exception(sprintf("'%s' must be an instance of '%s'.", $name, 'array'));
            }

            foreach ($input[$name] as $key => &$value) {
                if (is_int($key)) {
                    // Remove the data if it has no property name.
                    // If you try to pass a non-associative array as context, this will wipe that data.
                    unset($input[$name][$key]);
                    continue;
                }

                if (null === $value || is_bool($value)) {
                    $value = var_export($value, true);
                }

                // jsonify arrays and serializable classes
                if (is_array($value) || $value instanceof JsonSerializable) {
                    $value = json_encode($value, JSON_PRETTY_PRINT);
                }

                // stringify scalars and stringable classes
                if (is_scalar($value) || (is_object($value) && is_callable([$value, '__toString']))) {
                    $value = (string) $value;

                } elseif (is_object($value)) {
                    $value = sprintf('[object] %s', get_class($value));
                }

                if (is_resource($value)) {
                    $value = '[resource]';
                }
            }

            return $input[$name];
        }

        return $default;
    }