api/symfony/Component/Serializer/Debug/TraceableEncoder.yaml

77 lines
4.1 KiB
YAML
Raw Permalink Normal View History

2024-09-26 09:03:21 +00:00
name: TraceableEncoder
class_comment: '# * Collects some data about encoding.
# *
# * @author Mathias Arlaud <mathias.arlaud@gmail.com>
# *
# * @internal'
dependencies:
- name: SerializerDataCollector
type: class
source: Symfony\Component\Serializer\DataCollector\SerializerDataCollector
- name: DecoderInterface
type: class
source: Symfony\Component\Serializer\Encoder\DecoderInterface
- name: EncoderInterface
type: class
source: Symfony\Component\Serializer\Encoder\EncoderInterface
- name: NormalizationAwareInterface
type: class
source: Symfony\Component\Serializer\Encoder\NormalizationAwareInterface
- name: SerializerAwareInterface
type: class
source: Symfony\Component\Serializer\SerializerAwareInterface
- name: SerializerInterface
type: class
source: Symfony\Component\Serializer\SerializerInterface
properties: []
methods:
- name: __call
visibility: public
parameters:
- name: method
- name: arguments
comment: "# * Collects some data about encoding.\n# *\n# * @author Mathias Arlaud\
\ <mathias.arlaud@gmail.com>\n# *\n# * @internal\n# */\n# class TraceableEncoder\
\ implements EncoderInterface, DecoderInterface, SerializerAwareInterface\n# {\n\
# public function __construct(\n# private EncoderInterface|DecoderInterface $encoder,\n\
# private SerializerDataCollector $dataCollector,\n# ) {\n# }\n# \n# public function\
\ encode(mixed $data, string $format, array $context = []): string\n# {\n# if\
\ (!$this->encoder instanceof EncoderInterface) {\n# throw new \\BadMethodCallException(\\\
sprintf('The \"%s()\" method cannot be called as nested encoder doesn\\'t implements\
\ \"%s\".', __METHOD__, EncoderInterface::class));\n# }\n# \n# $startTime = microtime(true);\n\
# $encoded = $this->encoder->encode($data, $format, $context);\n# $time = microtime(true)\
\ - $startTime;\n# \n# if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID]\
\ ?? null)) {\n# $this->dataCollector->collectEncoding($traceId, $this->encoder::class,\
\ $time);\n# }\n# \n# return $encoded;\n# }\n# \n# public function supportsEncoding(string\
\ $format, array $context = []): bool\n# {\n# if (!$this->encoder instanceof EncoderInterface)\
\ {\n# return false;\n# }\n# \n# return $this->encoder->supportsEncoding($format,\
\ $context);\n# }\n# \n# public function decode(string $data, string $format,\
\ array $context = []): mixed\n# {\n# if (!$this->encoder instanceof DecoderInterface)\
\ {\n# throw new \\BadMethodCallException(\\sprintf('The \"%s()\" method cannot\
\ be called as nested encoder doesn\\'t implements \"%s\".', __METHOD__, DecoderInterface::class));\n\
# }\n# \n# $startTime = microtime(true);\n# $encoded = $this->encoder->decode($data,\
\ $format, $context);\n# $time = microtime(true) - $startTime;\n# \n# if ($traceId\
\ = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {\n# $this->dataCollector->collectDecoding($traceId,\
\ $this->encoder::class, $time);\n# }\n# \n# return $encoded;\n# }\n# \n# public\
\ function supportsDecoding(string $format, array $context = []): bool\n# {\n\
# if (!$this->encoder instanceof DecoderInterface) {\n# return false;\n# }\n#\
\ \n# return $this->encoder->supportsDecoding($format, $context);\n# }\n# \n#\
\ public function setSerializer(SerializerInterface $serializer): void\n# {\n\
# if (!$this->encoder instanceof SerializerAwareInterface) {\n# return;\n# }\n\
# \n# $this->encoder->setSerializer($serializer);\n# }\n# \n# public function\
\ needsNormalization(): bool\n# {\n# return !$this->encoder instanceof NormalizationAwareInterface;\n\
# }\n# \n# /**\n# * Proxies all method calls to the original encoder."
traits:
- Symfony\Component\Serializer\DataCollector\SerializerDataCollector
- Symfony\Component\Serializer\Encoder\DecoderInterface
- Symfony\Component\Serializer\Encoder\EncoderInterface
- Symfony\Component\Serializer\Encoder\NormalizationAwareInterface
- Symfony\Component\Serializer\SerializerAwareInterface
- Symfony\Component\Serializer\SerializerInterface
interfaces:
- EncoderInterface