function Serializer::serialize
Overrides SerializerInterface::serialize
File
-
vendor/
symfony/ serializer/ Serializer.php, line 122
Class
- Serializer
- Serializer serializes and deserializes data.
Namespace
Symfony\Component\SerializerCode
public final function serialize(mixed $data, string $format, array $context = []) : string {
if (!$this->supportsEncoding($format, $context)) {
throw new UnsupportedFormatException(\sprintf('Serialization for the format "%s" is not supported.', $format));
}
if ($this->encoder
->needsNormalization($format, $context)) {
$data = $this->normalize($data, $format, $context);
}
return $this->encode($data, $format, $context);
}