src/Money.php
public function allocateByRatios(array $ratios)
    {
        /** @var Money[] $result */
        $result = array();
        $total = array_sum($ratios);
        $remainder = $this->amount;

        for ($i = 0; $i < count($ratios); $i++) {
            $amount = $this->castToFloat($this->amount * $ratios[$i] / $total);
            $result[] = $this->newMoney($amount);
            $remainder -= $amount;
        }

        for ($i = 0; $i < $remainder; $i++) {
            $result[$i] = $this->newMoney($result[$i]->getAmount() + 1);
        }

        return $result;
    }
public function allocateByRatios(array $ratios)
    {
        /** @var Money[] $result */
        $result = array();
        $total = array_sum($ratios);
        $remainder = $this->amount;

        for ($i = 0; $i < count($ratios); $i++) {
            $amount = $this->castToFloat($this->amount * $ratios[$i] / $total);
            $result[] = $this->newMoney($amount);
            $remainder -= $amount;
        }

        for ($i = 0; $i < $remainder; $i++) {
            $result[$i] = $this->newMoney($result[$i]->getAmount() + 1);
        }

        return $result;
    }
public function allocateByRatios ( array $ ratios ) { /** @var Money[] $result */ $ result = array ( ) ; $ total = array_sum ( $ ratios ) ; $ remainder = $ this -> amount ; for ( $ i = 0 ; $ i < count ( $ ratios ) ; $ i ++ ) { $ amount = $ this -> castToFloat ( $ this -> amount * $ ratios [ $ i ] / $ total ) ; $ result [ ] = $ this -> newMoney ( $ amount ) ; $ remainder -= $ amount ; } for ( $ i = 0 ; $ i < $ remainder ; $ i ++ ) { $ result [ $ i ] = $ this -> newMoney ( $ result [ $ i ] -> getAmount ( ) + 1 ) ; } return $ result ; }
Allocate the monetary value represented by this Money object
using a list of ratios.

@param  array $ratios
@return Money[]
Allocate the monetary value represented by this Money object using a list of ratios .