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

Breadcrumb

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

function TraceableEncoder::decode

Overrides DecoderInterface::decode

File

vendor/symfony/serializer/Debug/TraceableEncoder.php, line 63

Class

TraceableEncoder
Collects some data about encoding.

Namespace

Symfony\Component\Serializer\Debug

Code

public function decode(string $data, string $format, array $context = []) : mixed {
    if (!$this->encoder instanceof DecoderInterface) {
        throw new \BadMethodCallException(\sprintf('The "%s()" method cannot be called as nested encoder doesn\'t implements "%s".', __METHOD__, DecoderInterface::class));
    }
    $startTime = microtime(true);
    $encoded = $this->encoder
        ->decode($data, $format, $context);
    $time = microtime(true) - $startTime;
    if ($traceId = $context[TraceableSerializer::DEBUG_TRACE_ID] ?? null) {
        $this->dataCollector
            ->collectDecoding($traceId, $this->encoder::class, $time, $this->serializerName);
    }
    return $encoded;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal