src/Money.php
public function allocateToTargets($n)
    {
        if (is_int($n)) {
            $n = (float)$n;
        }

        if (!is_float($n)) {
            throw new InvalidArgumentException('$n ' . \Yii::t('skeeks/money', 'must be an integer'));
        }

        $low = $this->newMoney(floatval($this->amount / $n));
        $high = $this->newMoney($low->getAmount() + 1);
        $remainder = $this->amount % $n;
        $result = array();

        for ($i = 0; $i < $remainder; $i++) {
            $result[] = $high;
        }

        for ($i = $remainder; $i < $n; $i++) {
            $result[] = $low;
        }

        return $result;
    }
public function allocateToTargets($n)
    {
        if (is_int($n)) {
            $n = (float)$n;
        }

        if (!is_float($n)) {
            throw new InvalidArgumentException('$n ' . \Yii::t('skeeks/money', 'must be an integer'));
        }

        $low = $this->newMoney(floatval($this->amount / $n));
        $high = $this->newMoney($low->getAmount() + 1);
        $remainder = $this->amount % $n;
        $result = array();

        for ($i = 0; $i < $remainder; $i++) {
            $result[] = $high;
        }

        for ($i = $remainder; $i < $n; $i++) {
            $result[] = $low;
        }

        return $result;
    }
public function allocateToTargets ( $ n ) { if ( is_int ( $ n ) ) { $ n = ( float ) $ n ; } if ( ! is_float ( $ n ) ) { throw new InvalidArgumentException ( '$n ' . \ Yii :: t ( 'skeeks/money' , 'must be an integer' ) ) ; } $ low = $ this -> newMoney ( floatval ( $ this -> amount / $ n ) ) ; $ high = $ this -> newMoney ( $ low -> getAmount ( ) + 1 ) ; $ remainder = $ this -> amount % $ n ; $ result = array ( ) ; for ( $ i = 0 ; $ i < $ remainder ; $ i ++ ) { $ result [ ] = $ high ; } for ( $ i = $ remainder ; $ i < $ n ; $ i ++ ) { $ result [ ] = $ low ; } return $ result ; }
Allocate the monetary value represented by this Money object
among N targets.

@param  integer|float $n
@return Money[]
@throws InvalidArgumentException
Allocate the monetary value represented by this Money object among N targets .