protected function createResultset(&$data, $type = null, $primaryId = null) {
		if ($type === null) {
			$type = $this->getResultType();
		}

		// Resultset = array
		if ($type & self::RESULTSET_ARRAY) {
			if ($data instanceof Traversable) {
				$data = iterator_to_array($data);
			}

			if ($type & (self::RESULT_ARRAY | self::RESULT_OBJECT)) {
				return $data;
			}

			if ($type & self::RESULT_MODEL) {
				return array_map([$this, 'create'], $data);
			}
		}

		// Resultset = collection
		if ($type & self::RESULTSET_COLLECTION) {
			if (! ($type & self::RESULT_MODEL)) {
				throw new Exceptions\InvalidResultType('Colection resultset works only with the models type');
			}
			
			if ($data instanceof Traversable) {
				$data = iterator_to_array($data);
			}

			return $this->createCollection($data, $primaryId);
		}

		// Resultset = iterator
		if ($type & self::RESULTSET_ITERATOR) {
			if (is_array($data)) {
				$data = new ArrayIterator($data);
			}

			if ($type & (self::RESULT_ARRAY | self::RESULT_OBJECT)) {
				return $data;
			}

			if ($type & self::RESULT_MODEL) {
				return $this->createIterator($data);
			}
		}

		throw new Exceptions\InvalidResultType('Nothing to do with the type #' . $type);
	}
protected function createResultset(&$data, $type = null, $primaryId = null) {
		if ($type === null) {
			$type = $this->getResultType();
		}

		// Resultset = array
		if ($type & self::RESULTSET_ARRAY) {
			if ($data instanceof Traversable) {
				$data = iterator_to_array($data);
			}

			if ($type & (self::RESULT_ARRAY | self::RESULT_OBJECT)) {
				return $data;
			}

			if ($type & self::RESULT_MODEL) {
				return array_map([$this, 'create'], $data);
			}
		}

		// Resultset = collection
		if ($type & self::RESULTSET_COLLECTION) {
			if (! ($type & self::RESULT_MODEL)) {
				throw new Exceptions\InvalidResultType('Colection resultset works only with the models type');
			}
			
			if ($data instanceof Traversable) {
				$data = iterator_to_array($data);
			}

			return $this->createCollection($data, $primaryId);
		}

		// Resultset = iterator
		if ($type & self::RESULTSET_ITERATOR) {
			if (is_array($data)) {
				$data = new ArrayIterator($data);
			}

			if ($type & (self::RESULT_ARRAY | self::RESULT_OBJECT)) {
				return $data;
			}

			if ($type & self::RESULT_MODEL) {
				return $this->createIterator($data);
			}
		}

		throw new Exceptions\InvalidResultType('Nothing to do with the type #' . $type);
	}
protected function createResultset ( & $ data , $ type = null , $ primaryId = null ) { if ( $ type === null ) { $ type = $ this -> getResultType ( ) ; } // Resultset = array if ( $ type & self :: RESULTSET_ARRAY ) { if ( $ data instanceof Traversable ) { $ data = iterator_to_array ( $ data ) ; } if ( $ type & ( self :: RESULT_ARRAY | self :: RESULT_OBJECT ) ) { return $ data ; } if ( $ type & self :: RESULT_MODEL ) { return array_map ( [ $ this , 'create' ] , $ data ) ; } } // Resultset = collection if ( $ type & self :: RESULTSET_COLLECTION ) { if ( ! ( $ type & self :: RESULT_MODEL ) ) { throw new Exceptions \ InvalidResultType ( 'Colection resultset works only with the models type' ) ; } if ( $ data instanceof Traversable ) { $ data = iterator_to_array ( $ data ) ; } return $ this -> createCollection ( $ data , $ primaryId ) ; } // Resultset = iterator if ( $ type & self :: RESULTSET_ITERATOR ) { if ( is_array ( $ data ) ) { $ data = new ArrayIterator ( $ data ) ; } if ( $ type & ( self :: RESULT_ARRAY | self :: RESULT_OBJECT ) ) { return $ data ; } if ( $ type & self :: RESULT_MODEL ) { return $ this -> createIterator ( $ data ) ; } } throw new Exceptions \ InvalidResultType ( 'Nothing to do with the type #' . $ type ) ; }
Create the resultset

Each element of the source (array | Iterator) must be an array or object

@param  array | Traversable $data
@param  int                 $type
@return mixed
Create the resultset