private function getNormalizer($data, ?string $format, array $context)
    {
        if ($this->cachedNormalizers !== $this->normalizers) {
            $this->cachedNormalizers = $this->normalizers;
            $this->denormalizerCache = $this->normalizerCache = [];
        }
        $type = \is_object($data) ? \get_class($data) : 'native-'.\gettype($data);

        if (!isset($this->normalizerCache[$format][$type])) {
            $this->normalizerCache[$format][$type] = [];

            foreach ($this->normalizers as $k => $normalizer) {
                if (!$normalizer instanceof NormalizerInterface) {
                    continue;
                }

                if (!$normalizer instanceof CacheableSupportsMethodInterface || !$normalizer->hasCacheableSupportsMethod()) {
                    $this->normalizerCache[$format][$type][$k] = false;
                } elseif ($normalizer->supportsNormalization($data, $format, $context)) {
                    $this->normalizerCache[$format][$type][$k] = true;
                    break;
                }
            }
        }

        foreach ($this->normalizerCache[$format][$type] as $k => $cached) {
            $normalizer = $this->normalizers[$k];
            if ($cached || $normalizer->supportsNormalization($data, $format, $context)) {
                return $normalizer;
            }
        }
    }
private function getNormalizer($data, ?string $format, array $context)
    {
        if ($this->cachedNormalizers !== $this->normalizers) {
            $this->cachedNormalizers = $this->normalizers;
            $this->denormalizerCache = $this->normalizerCache = [];
        }
        $type = \is_object($data) ? \get_class($data) : 'native-'.\gettype($data);

        if (!isset($this->normalizerCache[$format][$type])) {
            $this->normalizerCache[$format][$type] = [];

            foreach ($this->normalizers as $k => $normalizer) {
                if (!$normalizer instanceof NormalizerInterface) {
                    continue;
                }

                if (!$normalizer instanceof CacheableSupportsMethodInterface || !$normalizer->hasCacheableSupportsMethod()) {
                    $this->normalizerCache[$format][$type][$k] = false;
                } elseif ($normalizer->supportsNormalization($data, $format, $context)) {
                    $this->normalizerCache[$format][$type][$k] = true;
                    break;
                }
            }
        }

        foreach ($this->normalizerCache[$format][$type] as $k => $cached) {
            $normalizer = $this->normalizers[$k];
            if ($cached || $normalizer->supportsNormalization($data, $format, $context)) {
                return $normalizer;
            }
        }
    }
private function getNormalizer ( $ data , ? string $ format , array $ context ) { if ( $ this -> cachedNormalizers !== $ this -> normalizers ) { $ this -> cachedNormalizers = $ this -> normalizers ; $ this -> denormalizerCache = $ this -> normalizerCache = [ ] ; } $ type = \ is_object ( $ data ) ? \ get_class ( $ data ) : 'native-' . \ gettype ( $ data ) ; if ( ! isset ( $ this -> normalizerCache [ $ format ] [ $ type ] ) ) { $ this -> normalizerCache [ $ format ] [ $ type ] = [ ] ; foreach ( $ this -> normalizers as $ k => $ normalizer ) { if ( ! $ normalizer instanceof NormalizerInterface ) { continue ; } if ( ! $ normalizer instanceof CacheableSupportsMethodInterface || ! $ normalizer -> hasCacheableSupportsMethod ( ) ) { $ this -> normalizerCache [ $ format ] [ $ type ] [ $ k ] = false ; } elseif ( $ normalizer -> supportsNormalization ( $ data , $ format , $ context ) ) { $ this -> normalizerCache [ $ format ] [ $ type ] [ $ k ] = true ; break ; } } } foreach ( $ this -> normalizerCache [ $ format ] [ $ type ] as $ k => $ cached ) { $ normalizer = $ this -> normalizers [ $ k ] ; if ( $ cached || $ normalizer -> supportsNormalization ( $ data , $ format , $ context ) ) { return $ normalizer ; } } }
Returns a matching normalizer.

@param mixed  $data    Data to get the serializer for
@param string $format  Format name, present to give the option to normalizers to act differently based on formats
@param array  $context Options available to the normalizer

@return NormalizerInterface|null
Returns a matching normalizer .