function TraceableNormalizer::normalize
Overrides NormalizerInterface::normalize
File
-
vendor/
symfony/ serializer/ Debug/ TraceableNormalizer.php, line 43
Class
- TraceableNormalizer
- Collects some data about normalization.
Namespace
Symfony\Component\Serializer\DebugCode
public function normalize(mixed $object, ?string $format = null, array $context = []) : array|string|int|float|bool|\ArrayObject|null {
if (!$this->normalizer instanceof NormalizerInterface) {
throw new \BadMethodCallException(\sprintf('The "%s()" method cannot be called as nested normalizer doesn\'t implements "%s".', __METHOD__, NormalizerInterface::class));
}
$startTime = microtime(true);
$normalized = $this->normalizer
->normalize($object, $format, $context);
$time = microtime(true) - $startTime;
if ($traceId = $context[TraceableSerializer::DEBUG_TRACE_ID] ?? null) {
$this->dataCollector
->collectNormalization($traceId, $this->normalizer::class, $time, $this->serializerName);
}
return $normalized;
}