code: public function getCombination($quantity, $reset = false)
      {
          if (null !== $this->combination && !$reset) {
              return $this->combination;
          }
  
          $this->combination = null;
  
          if (!empty($combinations = $this->buildCombinations($quantity))) {
              // Sort combinations: prefer closest, then greater, then lower, finally smaller
              usort($combinations, function (AssignmentCombination $a, AssignmentCombination $b) use ($quantity) {
                  if ($a->diff == $b->diff) {
                      if ($a->size == $b->size) {
                          return 0;
                      }
  
                      return $a->size < $b->size ? -1 : 1;
                  }
  
                  if (0 <= $a->diff) {
                      return intval(0 > $b->diff ? -1 : $a->diff - $b->diff);
                  }
  
                  return intval(0 < $b->diff ? 1 : $b->diff - $a->diff);
              });
  
              $this->combination = reset($combinations);
          }
  
          return $this->combination;
      }
docs: Returns the best assignments combination for the given quantity.
  
  @param float $quantity
  @param bool  $reset
  
  @return AssignmentCombination