Symfony\Component\Serializer\Serializer::normalizeObject PHP Method

normalizeObject() private method

Normalizes an object into a set of arrays/scalars
private normalizeObject ( object $object, string $format = null ) : array | scalar
$object object object to normalize
$format string format name, present to give the option to normalizers to act differently based on formats
return array | scalar
    private function normalizeObject($object, $format = null)
    {
        if (!$this->normalizers) {
            throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
        }
        $class = get_class($object);
        if (isset($this->normalizerCache[$class][$format])) {
            return $this->normalizerCache[$class][$format]->normalize($object, $format);
        }
        foreach ($this->normalizers as $normalizer) {
            if ($normalizer->supportsNormalization($object, $class, $format)) {
                $this->normalizerCache[$class][$format] = $normalizer;

                return $normalizer->normalize($object, $format);
            }
        }
        throw new UnexpectedValueException('Could not normalize object of type '.$class.', no supporting normalizer found.');
    }