Money\Money::add PHP Method

add() public method

Returns a new Money object that represents the sum of this and another Money object
public add ( Money $addend ) : Money
$addend Money
return Money
    public function add(Money $addend)
    {
        $this->assertSameCurrencyAs($addend);
        $amount = bcadd($this->amount, $addend->amount, self::SCALE);
        return $this->newInstance($amount);
    }

Usage Example

 /**
  * @param PlanDefinition $definition
  * @param Money $amountToPay
  * @param PlanParameters $parameters
  * @internal param string $planCode
  * @return \Ice\PaymentPlan\PaymentPlan
  */
 public function getPlan(PlanDefinition $definition, Money $amountToPay, PlanParameters $parameters)
 {
     if ($parameters->hasParameter('bursary_total_deduction') && ($bursaryTotalDeduction = intval($parameters->get('bursary_total_deduction'))) > 0) {
         $absoluteBursaryTotal = Money::GBP($bursaryTotalDeduction);
         $amountBeforeBursary = $amountToPay->add($absoluteBursaryTotal);
         $planWithoutBursary = $this->childCalculator->getPlan($definition, $amountBeforeBursary, $parameters);
         return $this->subtractBursaryFromPlan($planWithoutBursary, $absoluteBursaryTotal);
     }
     return $this->childCalculator->getPlan($definition, $amountToPay, $parameters);
 }
All Usage Examples Of Money\Money::add