public function toCollection($data): ICollection
	{
		if ($data instanceof QueryBuilder) {
			return new DbalCollection($this, $this->connection, $data);

		} elseif (is_array($data)) {
			$storageReflection = $this->getStorageReflection();
			$result = array_map([$this->getRepository(), 'hydrateEntity'], array_map([$storageReflection, 'convertStorageToEntity'], $data));
			return new ArrayCollection($result, $this->getRepository());

		} elseif ($data instanceof Result) {
			$result = [];
			$repository = $this->getRepository();
			$storageReflection = $this->getStorageReflection();
			foreach ($data as $row) {
				$result[] = $repository->hydrateEntity($storageReflection->convertStorageToEntity($row->toArray()));
			}
			return new ArrayCollection($result, $this->getRepository());
		}

		throw new InvalidArgumentException('DbalMapper can convert only array|QueryBuilder|Result to ICollection.');
	}
public function toCollection($data): ICollection
	{
		if ($data instanceof QueryBuilder) {
			return new DbalCollection($this, $this->connection, $data);

		} elseif (is_array($data)) {
			$storageReflection = $this->getStorageReflection();
			$result = array_map([$this->getRepository(), 'hydrateEntity'], array_map([$storageReflection, 'convertStorageToEntity'], $data));
			return new ArrayCollection($result, $this->getRepository());

		} elseif ($data instanceof Result) {
			$result = [];
			$repository = $this->getRepository();
			$storageReflection = $this->getStorageReflection();
			foreach ($data as $row) {
				$result[] = $repository->hydrateEntity($storageReflection->convertStorageToEntity($row->toArray()));
			}
			return new ArrayCollection($result, $this->getRepository());
		}

		throw new InvalidArgumentException('DbalMapper can convert only array|QueryBuilder|Result to ICollection.');
	}
public function toCollection ( $ data ) : ICollection { if ( $ data instanceof QueryBuilder ) { return new DbalCollection ( $ this , $ this -> connection , $ data ) ; } elseif ( is_array ( $ data ) ) { $ storageReflection = $ this -> getStorageReflection ( ) ; $ result = array_map ( [ $ this -> getRepository ( ) , 'hydrateEntity' ] , array_map ( [ $ storageReflection , 'convertStorageToEntity' ] , $ data ) ) ; return new ArrayCollection ( $ result , $ this -> getRepository ( ) ) ; } elseif ( $ data instanceof Result ) { $ result = [ ] ; $ repository = $ this -> getRepository ( ) ; $ storageReflection = $ this -> getStorageReflection ( ) ; foreach ( $ data as $ row ) { $ result [ ] = $ repository -> hydrateEntity ( $ storageReflection -> convertStorageToEntity ( $ row -> toArray ( ) ) ) ; } return new ArrayCollection ( $ result , $ this -> getRepository ( ) ) ; } throw new InvalidArgumentException ( 'DbalMapper can convert only array|QueryBuilder|Result to ICollection.' ) ; }
Transforms value from mapper, which is not a collection.
@param  QueryBuilder|array|Result $data
Transforms value from mapper which is not a collection .