@param string $serializer

@return Serializer
9306
public static function getSerializer(string $serializer): Serializer
    {
        if (!isset(self::$serializers[$serializer])) {
            switch ($serializer) {
                case 'php':
                    self::$serializers[$serializer] = new PhpSerializer();
                    break;

                case 'json':
                    self::$serializers[$serializer] = new JsonSerializer();
                    break;

                case 'yaml':
                    self::$serializers[$serializer] = new YamlSerializer();
                    break;

                default:
                    throw new \InvalidArgumentException(sprintf('Serializer [%s] is not supported.', $serializer));
            }
        }

        return self::$serializers[$serializer];
    }
275155
public static <T> Array2dJsonSerializer<T> newInstance( JsonSerializer<T> serializer ) {
        return new Array2dJsonSerializer<T>( serializer );
    }
870451
public static function createResponseModelTransformer(SerializerInterface $serializer = null)
    {
        $serializer = self::prepareSerializer($serializer);

        return new ResponseModelTransformer($serializer);
    }
712590
def _create_serializer(self) -> JsonObjectSerializer:
        
        if self._serializer_cache is None:
            serializer_cls = type(
                "%sInternalSerializer" % type(self),
                (JsonObjectSerializer,),
                {
                    "_JSON_ENCODER_ARGS": self._args,
                    "_JSON_ENCODER_KWARGS": self._kwargs
                }
            )
            self._serializer_cache = serializer_cls(self._get_property_mappings())
        return self._serializer_cache
1370293
public function serializer($type = null)
    {
        $type = $type ?? 'php';

        if (isset($this->serializers[$type])) {
            return $this->serializers[$type];
        }

        return $this->serializers[$type] = $this->resolve($type);
    }
1315675
public function addNormalizer($normalizer)
    {
        if ($normalizer instanceof NormalizerInterface) {
            $this->normalizers[] = $normalizer;
        }
        if ($normalizer instanceof DenormalizerInterface) {
            $this->denormalizers[] = $normalizer;
        }
        if ($normalizer instanceof SerializerAwareInterface && $this->serializer) {
            $normalizer->setSerializer($this->serializer);
        }
        return $this;
    }
21422
public static function unserialize(Serializer $serializer, $className, array $value)
    {
        $ref = new ReflectionClass($className);

        return self::fillObjectProperties(self::getTypedValue($serializer, $value), $ref);
    }
550392
public static function create($data = null, $transformer = null, $serializer = null)
    {
        $fractal = parent::create($data, $transformer, $serializer);

        if (config('fractal.auto_includes.enabled')) {
            $requestKey = config('fractal.auto_includes.request_key');

            if ($include = app('request')->query($requestKey)) {
                $fractal->parseIncludes($include);
            }
        }

        if (empty($serializer)) {
            $serializer = config('fractal.default_serializer');
        }

        if ($data instanceof LengthAwarePaginator) {
            $paginator = config('fractal.default_paginator');

            if (empty($paginator)) {
                $paginator = IlluminatePaginatorAdapter::class;
            }

            $fractal->paginateWith(new $paginator($data));
        }

        if (empty($serializer)) {
            return $fractal;
        }

        if ($serializer instanceof SerializerAbstract) {
            return $fractal->serializeWith($serializer);
        }

        if ($serializer instanceof Closure) {
            return $fractal->serializeWith($serializer());
        }

        if ($serializer == JsonApiSerializer::class) {
            $baseUrl = config('fractal.base_url');

            return $fractal->serializeWith(new $serializer($baseUrl));
        }

        return $fractal->serializeWith(new $serializer);
    }
1286089
private function getUrlFileSerializer()
    {
        if ($this->urlFileSerializer === null) {
            $this->urlFileSerializer = new UrlFileSerializer();
            $this->urlFileSerializer->setServiceLocator($this->getServiceLocator());
        }

        return $this->urlFileSerializer;
    }
930410
public function unserialize($data)
    {
        $object = @unserialize($data);
        if($object === false) {
            throw new SerializerException("Unable to unserialize data: " . $data);
        }

        return $object;
    }
220981
public function getTypeSerializer()
    {
        if (isset(self::$serializerTypeMap[$this->getType()])) {
            return self::$serializerTypeMap[$this->getType()];
        }

        // our fallback default
        return self::$serializerTypeMap[self::TYPE_STRING];
    }
1128383
public static function toArray(ResourceAbstract $resource, $serializer = DataArraySerializer::class)
    {
        $manager = new Manager();
        $manager->setSerializer(new $serializer());
        return $manager->createData($resource)->toArray();
    }
383450
public static <T> ArrayJsonSerializer<T> newInstance( JsonSerializer<T> serializer ) {
        return new ArrayJsonSerializer<T>( serializer );
    }
667214
public static function createResourceModelTransformer(SerializerInterface $serializer = null)
    {
        $serializer = self::prepareSerializer($serializer);

        return new ResourceModelTransformer($serializer);
    }
1275612
protected function serializerFor($object): ObjectXmlSerializer
    {
        if (!annotationsOf($object)->contain('XmlSerializer')) {
            return AnnotationBasedObjectXmlSerializer::fromObject($object);
        }

        return $this->injector->getInstance(
                annotationsOf($object)
                        ->firstNamed('XmlSerializer')
                        ->getValue()
                        ->getName()
        );
    }
667069
public function isValidSerializer($serializer): bool
    {
        if ($serializer === false) {
            // False is a valid value (forces serialization to be off)
            return true;
        }
        if ($serializer instanceof SerializerInterface) {
            return true;
        }
        if (\is_callable($serializer)) {
            return true;
        }

        return false;
    }
676698
protected function serializeResource(FractalSerializerAbstract $serializer, $data)
    {
        $resourceKey = $this->resource->getResourceKey();

        if ($this->resource instanceof FractalCollection) {
            return $serializer->collection($resourceKey, $data);
        } elseif ($this->resource instanceof FractalItem) {
            return $serializer->item($resourceKey, $data);
        } elseif ($this->resource instanceof NodesResourceContent) {
            return (! empty($resourceKey)) ? [$resourceKey => $data] : $data;
        }

        return $serializer->null();
    }