src/Transformations/TransformationFactory.php
public function serialize($serializer = ApiDataSerializer::class): array
	{
		if (! is_a($serializer, SerializerAbstract::class, true)) {
			throw new \InvalidArgumentException(
				sprintf('The serializer must either be an instance,
				or string representation of %s. The passed value %s is neither.',
					SerializerAbstract::class,
					$serializer
				)
			);
		}

		$this->serializer = is_string($serializer) ? new $serializer : $serializer;

		$this->manager->setSerializer($this->serializer);

		return $this->manager->createData($this->resource)->toArray();
	}
public function serialize($serializer = ApiDataSerializer::class): array
	{
		if (! is_a($serializer, SerializerAbstract::class, true)) {
			throw new \InvalidArgumentException(
				sprintf('The serializer must either be an instance,
				or string representation of %s. The passed value %s is neither.',
					SerializerAbstract::class,
					$serializer
				)
			);
		}

		$this->serializer = is_string($serializer) ? new $serializer : $serializer;

		$this->manager->setSerializer($this->serializer);

		return $this->manager->createData($this->resource)->toArray();
	}
public function serialize ( $ serializer = ApiDataSerializer :: class ) : array { if ( ! is_a ( $ serializer , SerializerAbstract :: class , true ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The serializer must either be an instance,
				or string representation of %s. The passed value %s is neither.' , SerializerAbstract :: class , $ serializer ) ) ; } $ this -> serializer = is_string ( $ serializer ) ? new $ serializer : $ serializer ; $ this -> manager -> setSerializer ( $ this -> serializer ) ; return $ this -> manager -> createData ( $ this -> resource ) -> toArray ( ) ; }
Completes the the transformation and serialization flow, returning the data.

This could be thought of as a `flush` method.

// @TODO it does too much currently. toArray is really the `flush` method and should be moved into it's own
method.

@param \League\Fractal\Serializer\SerializerAbstract|string $serializer

@return array
Completes the the transformation and serialization flow returning the data .