Stock/Prioritizer/UnitCandidate.php
private function buildCombinations($quantity)
    {
        if (empty($this->map)) {
            return [];
        }

        $combinations = [];

        // Size 1
        foreach ($this->map as $id => $qty) {
            $combinations[] = new AssignmentCombination([$id => $qty], $diff = $qty - $quantity);

            if ($diff == 0) {
                return $combinations;
            }
        }

        // Size 1 < size < max
        for ($length = 2; $length < count($this->map); $length++) {
            foreach (combine_assoc($this->map, $length) as $map) {
                $combinations[] = new AssignmentCombination($map, $diff = array_sum($map) - $quantity);

                if ($diff == 0) {
                    return $combinations;
                }
            }
        }

        // Size max
        $combinations[] = new AssignmentCombination($this->map, array_sum($this->map) - $quantity);

        return $combinations;
    }
private function buildCombinations($quantity)
    {
        if (empty($this->map)) {
            return [];
        }

        $combinations = [];

        // Size 1
        foreach ($this->map as $id => $qty) {
            $combinations[] = new AssignmentCombination([$id => $qty], $diff = $qty - $quantity);

            if ($diff == 0) {
                return $combinations;
            }
        }

        // Size 1 < size < max
        for ($length = 2; $length < count($this->map); $length++) {
            foreach (combine_assoc($this->map, $length) as $map) {
                $combinations[] = new AssignmentCombination($map, $diff = array_sum($map) - $quantity);

                if ($diff == 0) {
                    return $combinations;
                }
            }
        }

        // Size max
        $combinations[] = new AssignmentCombination($this->map, array_sum($this->map) - $quantity);

        return $combinations;
    }
Builds the assignments releasable quantity combination list.

@param float $quantity

@return AssignmentCombination[]