You are here

public function PriceModified::add in Price 3.x

Same name and namespace in other branches
  1. 8 src/PriceModified.php \Drupal\price\PriceModified::add()
  2. 3.0.x src/PriceModified.php \Drupal\price\PriceModified::add()

Adds the given price to the current price.

Parameters

\Drupal\price\PriceModified $price: The price.

Return value

static The resulting price.

File

src/PriceModified.php, line 127

Class

PriceModified
Provides a value object for monetary values.

Namespace

Drupal\price

Code

public function add(PriceModified $price) {
  $this
    ->assertSameCurrency($this, $price);
  $new_number = Calculator::add($this->number, $price
    ->getNumber());
  return new static($new_number, $this->currencyCode, $this->modifier);
}