Apply multiple serializers to some data

@param array $serializers An array of Serializers to apply
@param mixed $data The data being serialized
@return mixed The serialized data, possibly unchanged
504551
public static function applySerializers(array $serializers, $data) {
		return array_reduce($serializers, function ($serializedData, $serializer) {
			return $serializer->apply($serializedData);
		}, $data);
	}
731581
public function deserialize(array $data)
    {
        $this->assertHasKey('name', $data);
        $this->assertHasKey('conditions', $data);

        if ( ! is_array($data['conditions'])) {
            throw new RuntimeException('Key "conditions" should be an array.');
        }

        $toggle = new Toggle(
            $data['name'],
            $this->deserializeConditions($data['conditions']),
            isset($data['strategy']) ? $this->deserializeStrategy($data['strategy']) : Toggle::STRATEGY_AFFIRMATIVE
        );

        if (isset($data['status'])) {
            $this->deserializeStatus($toggle, $data['status']);
        }

        return $toggle;
    }
740214
public function unserialize( $serialization ) {
		$serializationData = unserialize( $serialization );

		foreach ( $serializationData['data'] as $offset => $value ) {
			// Just set the element, bypassing checks and offset resolving,
			// as these elements have already gone through this.
			parent::offsetSet( $offset, $value );
		}

		$this->indexOffset = $serializationData['index'];

		$this->typePointers = $serializationData['typePointers'];

		if ( array_key_exists( 'assoc', $serializationData ) ) {
			$this->isAssociative = $serializationData['assoc'] === 'n' ? null : $serializationData['assoc'] === 't';
		}
	}
667757
public function deserialize($data)
    {
        $result = json_decode($data, true);
        if ($result === null) {
            return $data;
        }
        return $result;
    }
1042285
public function serialize($data)
    {
        if (version_compare($this->productMetadata->getVersion(), '2.2.0', '>=')) {
            $objManager = \Magento\Framework\App\ObjectManager::getInstance();
            /** @var \Magento\Framework\Serialize\Serializer\Json $serializer */
            $serializer = $objManager->create('Magento\Framework\Serialize\Serializer\Json');
            return $serializer->serialize($data);
        }

        $result = json_encode($data);
        if (false === $result) {
            throw new \InvalidArgumentException('Unable to serialize value.');
        }
        return $result;
    }
710141
function serialize(array $data) {
        $preSerialized = array();
        $serialized = '';

        if (count($data)) {
            foreach ($data as $bucket => $bucketData) {
                $preSerialized[] = $bucket . '|' . serialize($bucketData);
            }
            $serialized = implode('', $preSerialized);
        }

        return $serialized;
    }
1134037
public function unserialize($data)
    {
        $data = unserialize($data);

        $this->setData($data);

        return $this->getData();
    }
1045891
public function unserialize($serialized = null)
    {
        if (is_null($serialized)) {
            return unserialize($this->serialize);
        }

        return unserialize($serialized);
    }
78888
public static function deserializeObject(array $data)
    {
        /** @var Bulk $result */
        $result = parent::deserializeObject($data);
        $result->maxOperations = $data['maxOperations'];
        $result->maxPayloadSize = $data['maxPayloadSize'];

        return $result;
    }
1071382
public function serialize($data)
    {
        if (is_array($data) || (is_object($data) && !method_exists($data, '_toString'))) {
            throw new \InvalidArgumentException(__CLASS__ . ' can not handle an array or non-stringable object.');
        }

        return $data;
    }
122619
private function unserializeArray(array $data)
    {
        $unserialized = [];

        foreach ($data as $key => $value) {
            if ($value instanceof ObjectStub) {
                $unserialized[$key] = $value->getObject();

                continue;
            }

            $unserialized[$key] = is_array($value) ? $this->unserializeArray($value) : $value;
        }

        return $unserialized;
    }
1333795
public function add($serializer)
    {
        if (!method_exists($serializer, 'serialize')) {
            throw new \Exception('The serializer '.get_class($serializer).' must implement the method serialize');
        }

        $this->serializers[] = $serializer;
    }
397171
protected static function missingCreationAttributes(array $data, JsonApiSerializer $serializer)
    {
        $inputAttributes = array_keys($data[JsonApiTransformer::ATTRIBUTES_KEY]);

        $mapping = $serializer->getTransformer()->getMappingByAlias($data[JsonApiTransformer::TYPE_KEY]);

        $diff = [];
        if (null !== $mapping) {
            $required = $mapping->getRequiredProperties();
            $properties = str_replace(
                array_keys($mapping->getAliasedProperties()),
                array_values($mapping->getAliasedProperties()),
                !empty($required) ? $required : $mapping->getProperties()
            );
            $properties = array_diff($properties, $mapping->getIdProperties());

            $diff = (array) array_diff($properties, $inputAttributes);
        }

        return $diff;
    }
358347
public function resolve(array $headers)
    {
        if (!isset($headers[HeaderTypeEnum::CONTENT_TYPE]) ||
            !isset($this->messageSerializers[$headers[HeaderTypeEnum::CONTENT_TYPE]])
        ) {
            return $this->defaultSerializer;
        }

        return $this->messageSerializers[$headers[HeaderTypeEnum::CONTENT_TYPE]];
    }
1207109
public function serialize($subject, &$data = array(), SerializerInterface $serializer = null)
    {
        $context = $this->serializer();
        $context($subject, $data, $serializer);
        return $data;
    }
680979
private function serialize($data)
    {
        if ($this->type == 'db') {
            return $this->db->encode($data, $this->packed);
        }

        return $this->packed ? serialize($data) : $data;
    }
501804
protected static function getTypedValue(Serializer $serializer, array $value)
    {
        foreach ($value as &$v) {
            $v = $serializer->unserialize($v);
        }

        return $value;
    }