Transform a set of objects into a set of items.

@param array $objects

@return Item[]
180595
public function toItems(array $objects): array
    {
        $items = [];
        foreach ($objects as $object) {
            $item = $this->toItem($object);
            if ($item instanceof Item) {
                $items[] = $item;
            }
        }

        return $items;
    }
550643
public function filter(array $items): array
    {
        if (isset($items[$this->keyToUnset])) {
            unset($items[$this->keyToUnset]);
        }

        return $items;
    }
490312
public function mapObjectsToRows($objects, $meta=null, $context=null)
    {
        if (!$objects) { return []; }

        if (!$meta instanceof Meta) {
            $meta = $this->getMeta($meta ?: get_class(current($objects)));
        }

        $out = [];
        foreach ($objects as $key => $object) {
            $out[$key] = $this->mapObjectToRow($object, $meta, $context);
        }
        return $out;
    }
990029
protected function map( array $items )
	{
		$list = [];

		foreach( $items as $item ) {
			$list[$item->getCode()] = $item;
		}

		return $list;
	}
974133
protected function getArrayableItems($items): array
    {
        if (is_array($items)) {
            return $items;
        } elseif (is_callable($items)) {
            return call_user_func($items);
        } elseif ($items instanceof self) {
            return $items->all();
        } elseif ($items instanceof Iterator) {
            return $items;
        } elseif ($items instanceof Traversable) {
            return iterator_to_array($items);
        } elseif ($items instanceof IteratorAggregate) {
            return $items->getIterator();
        } elseif ($items instanceof JsonSerializable) {
            return $items->jsonSerialize();
        } elseif (method_exists($items, 'toJson')) {
            return json_decode($items->toJson(), true);
        } elseif (method_exists($items, 'toArray')) {
            return $items->toArray();
        }

        return (array) $items;
    }
709468
protected function toArray( array $items )
	{
		$data = [];

		foreach( $items as $item )
		{
			foreach( $item->toArray( true ) as $key => $value ) {
				$data[$key][] = $value;
			}
		}

		return $data;
	}
1141750
static public function toCollections($object) {
        if ($object === null) {
            return null;
        }

        if (!is_array($object)) {
            if (is_object($object)) {
                foreach ($object as $key => $value) {
                    $object->$key = self::toCollections($value);
                }
            }
            return $object;
        }

        if (empty($object)) {
            return new Map();
        }

        $elements = array();
        $isList = true;
        $lastKey = -1;

        foreach ($object as $key => $element) {
            $elements[$key] = self::toCollections($element);

            if (!is_int($key) || intval($key) != $lastKey + 1) {
                $isList = false;
            }
            $lastKey = intval($key);
        }

        if ($isList) {
            return new Liste($elements);
        } else {
            return new Map($elements);
        }
    }
463669
protected function getItemsAsArray($items)
    {
        if (is_array($items)) {
            return $items;
        } elseif ($items instanceof self) {
            return $items->all();
        } elseif ($items instanceof Traversable) {
            return iterator_to_array($items);
        }

        return (array) $items;
    }
191288
private function itemsFromArray(array $data): array
    {
        $objects = [];
        foreach ($data[$this->key()] as $objectData) {
            $objects[] = $this->item->from($objectData);
        }
        return $objects;
    }
762889
protected function getItems( $items )
	{
		if (is_array($items))
		{
			return $items;
		}
		if($items instanceof self)
		{
			return $items->getAll();
		}
		if($items instanceof Arrayable)
		{
			return $items->toArray();
		}
		if($items instanceof Jsonable)
		{
			return json_decode($items->toJson(), true);
		}
		if($items instanceof JsonSerializable)
		{
			return $items->jsonSerialize();
		}
		if($items instanceof Traversable)
		{
			return iterator_to_array($items);
		}

		return (array) $items;
	}
855354
private function processSortBy($objects)
    {
        if (count($objects) > 0) {
            foreach ($objects as $key => $row) {
                if (array_key_exists($this->sortByField, $row)) {
                    $sort[$key] = $row[$this->sortByField];
                }
            }

            array_multisort($sort, $this->sortByDirection, $objects);
        }

        return $objects;
    }
387778
static function GetKeyList(array $objects)
    {
        $result = array();
        foreach ($objects as $object) {
            $result[] = $object->KeyValue();
        }
        return $result;
    }
214197
public function transformToArray()
    {
        $transformedEd               = [];
        $transformedEd['collection'] = $this->getRelation();
        $transformedEd['from']       = $this->getFromCollections();
        $transformedEd['to']         = $this->getToCollections();

        return $transformedEd;
    }
97090
public static function transmute($items)
    {
        if (is_array($items)) {
            return $items;
        } elseif ($items instanceof Collection) {
            return $items->all();
        }

        return (array) $items;
    }
403251
private function buildSubjects(array $objects)
    {
        $subjects = [];

        foreach ($objects as $object) {
            $subject = SubjectIdentity::fromObject($object);
            $id = SharingUtils::getCacheId($subject);

            if (!\array_key_exists($id, $this->cacheSubjectSharing)
                    && $this->hasIdentityPermissible()
                    && $this->hasSharingVisibility($subject)
                    && $this->hasSubjectConfig($subject->getType())) {
                $subjects[$id] = $subject;
                $this->cacheSubjectSharing[$id] = false;
            }
        }

        return $subjects;
    }
690878
protected function setCartItems($items)
    {
        return (new Collection($items))->map(function ($item, $num) {
            return [
                'L_PAYMENTREQUEST_0_NAME'.$num => $item['name'],
                'L_PAYMENTREQUEST_0_AMT'.$num  => $item['price'],
                'L_PAYMENTREQUEST_0_QTY'.$num  => isset($item['qty']) ? $item['qty'] : 1,
            ];
        })->flatMap(function ($value) {
            return $value;
        });
    }
1207405
protected function assignToHandlers(array $objects)
    {
        $result = [];
        $perType = TypedUtils::groupByType($objects);
        foreach ($this->handlers as $handler) {
            $remainingTypes = array_keys($perType);
            $handlerTypes = $handler->getSupportedEntityTypes();
            $useTypes = $handlerTypes === null ? $remainingTypes : array_intersect($handlerTypes, $remainingTypes);
            if (count($useTypes) > 0) {
                $assigned = [];
                foreach ($useTypes as $type) {
                    $assigned[] = $perType[$type];
                    unset($perType[$type]);
                }
                $result[] = [$handler, Arrays::flatten($assigned)];
                if (count($perType) === 0) {
                    // Done
                    break;
                }
            }
        }

        return $result;
    }