Common/Calculator/Amount.php
public function merge(Amount ...$amounts): void
    {
        foreach ($amounts as $amount) {
            if ($amount->getCurrency() !== $this->currency) {
                throw new RuntimeException("Currencies miss match.");
            }
            $this->unit += $amount->getUnit();
            $this->gross += $amount->getGross();
            $this->discount += $amount->getDiscount();
            $this->base += $amount->getBase();
            $this->tax += $amount->getTax();
            $this->total += $amount->getTotal();

            foreach ($amount->getDiscountAdjustments() as $a) {
                $this->addDiscountAdjustment($a);
            }

            foreach ($amount->getTaxAdjustments() as $a) {
                $this->addTaxAdjustment($a);
            }
        }
    }
public function merge(Amount ...$amounts): void
    {
        foreach ($amounts as $amount) {
            if ($amount->getCurrency() !== $this->currency) {
                throw new RuntimeException("Currencies miss match.");
            }
            $this->unit += $amount->getUnit();
            $this->gross += $amount->getGross();
            $this->discount += $amount->getDiscount();
            $this->base += $amount->getBase();
            $this->tax += $amount->getTax();
            $this->total += $amount->getTotal();

            foreach ($amount->getDiscountAdjustments() as $a) {
                $this->addDiscountAdjustment($a);
            }

            foreach ($amount->getTaxAdjustments() as $a) {
                $this->addTaxAdjustment($a);
            }
        }
    }
public function merge ( Amount ... $ amounts ) : void { foreach ( $ amounts as $ amount ) { if ( $ amount -> getCurrency ( ) !== $ this -> currency ) { throw new RuntimeException ( "Currencies miss match." ) ; } $ this -> unit += $ amount -> getUnit ( ) ; $ this -> gross += $ amount -> getGross ( ) ; $ this -> discount += $ amount -> getDiscount ( ) ; $ this -> base += $ amount -> getBase ( ) ; $ this -> tax += $ amount -> getTax ( ) ; $ this -> total += $ amount -> getTotal ( ) ; foreach ( $ amount -> getDiscountAdjustments ( ) as $ a ) { $ this -> addDiscountAdjustment ( $ a ) ; } foreach ( $ amount -> getTaxAdjustments ( ) as $ a ) { $ this -> addTaxAdjustment ( $ a ) ; } } }
Merges the given amounts (by sum).

@param Amount[] $amounts
Merges the given amounts ( by sum ) .