@param PackedBox[] $packedBoxes

@return PackedBox
161255
private function findBestBoxFromIteration($packedBoxes): PackedBox
    {
        //Check iteration was productive
        if (count($packedBoxes) === 0) {
            throw new ItemTooLargeException('Item ' . $this->items->top()->getDescription() . ' is too large to fit into any box', $this->items->top());
        }

        usort($packedBoxes, [$this, 'compare']);

        return array_shift($packedBoxes);
    }
1133036
public function withAttachments($attachments)
    {
        if (! is_array($attachments)) {
            $attachments = [$attachments];
        }

        foreach ($attachments as $attachment) {
            $this->withAttachment($attachment);
        }

        return $this;
    }
879218
public static function merge(array $containers)
    {
        $attributeBags = array();

        $weight = 0;
        foreach($containers as $container)
        {
            $weight = max($weight, $container->getWeight());
            $attributeBags[] = $container->getAttributeBag();
        }

        $container = new static();
        $container->attributeBag = AttributeBag::merge($attributeBags);
        $container->weight = $weight;
        
        return $container;
    }
1088148
public function mountFilesystems(array $filesystems)
    {
        foreach ($filesystems as $prefix => $filesystem) {
            $this->mountFilesystem($prefix, $filesystem);
        }

        return $this;
    }
1365488
public function useSortings(Sortings $sortings)
    {
        foreach($sortings->getSortings() as $sorting) {
            $this->useSorting($sorting);
        }

        return $this;
    }
317358
private function mergeSettings(Collection $remotes, Collection $locals): ArrayCollection
    {
        $settings = $remotes->toArray();

        /** @var SettingInterface $local */
        foreach ($locals->toArray() as $local) {
            if (!$this->exists($remotes, $local)) {
                $settings[] = $local;
            }
        }

        return new ArrayCollection($settings);
    }
360368
protected function sortAndSavePackageStates(array $packageStates)
    {
        $orderedPackageStates = $this->sortAvailablePackagesByDependencies($packageStates);
        $this->savePackageStates($orderedPackageStates);

        return $orderedPackageStates;
    }
519131
private function getBox(array $coordinates)
    {
        $height = abs($coordinates['y1'] - $coordinates['y2']);
        $width = abs($coordinates['x1'] - $coordinates['x2']);

        return new Box($width, $height);
    }
232200
public function loadAll(array $columnNames = null)
    {
        if (is_array($columnNames)) {
            foreach ($columnNames as $columnName) {
                $this->columnsToLoad[$columnName] = $this->structure->getColumn($columnName);
            }
        } else {
            $this->columnsToLoad = $this->structure->getColumns();
        }

        return $this;
    }
342155
public function setCheckboxes(array $checkboxes)
    {
        foreach ($checkboxes as $name => $label) {
            $this->checkboxes[$label] = new CmsCheckbox($name);
        }

        return $this;
    }
319288
public function importBlocks(array $blocks)
    {
        foreach ($blocks as $name => $list) {
            foreach ($list as $block) {
                /* @var BlockElement $block */
                $block->addCompiler($this);
            }
        }

        return $this;
    }
147835
public function registerPackages(array $packages)
    {
        foreach ($packages as $alias => $package) {
            $this->addPackage($alias, $package);
        }

        return $this;
    }
406226
public function loadCollection(array $parameters = [], array $headers = [])
    {
        return $this->createCollection(
            $this->getApi()->getGenres($parameters, $headers)
        );
    }
1361742
protected function implementVOs(array $datas = array())
    {
        $ret = array();

        if (!$class = $this->getVOFQCN()) {
            throw new \RuntimeException('VOFQCN is not defined for ' . get_called_class());
        }

        $datas = $this->translationLoader($class, $datas);

        foreach ($datas as &$row) {
            $ret[$row[$this->getIdentityColumn()]] = new $class($row);
        }

        return $ret;
    }
881584
public function buildNewCollection(array $children) : \Dms\Core\Model\ITypedCollection
    {
        return $this->mapper->buildCollection($children);
    }
1152844
public function loadTvCollection(array $parameters = [], array $headers = [])
    {
        return $this->createCollection(
            $this->getApi()->getTvGenres($parameters, $headers)
        );
    }
1198686
public function top(): PackedBox
    {
        if (!$this->isSorted) {
            usort($this->list, [$this, 'compare']);
            $this->isSorted = true;
        }

        return reset($this->list);
    }