You are here

public function Price::add in Price 8

Same name and namespace in other branches
  1. 3.x src/Price.php \Drupal\price\Price::add()
  2. 2.0.x src/Price.php \Drupal\price\Price::add()
  3. 2.x src/Price.php \Drupal\price\Price::add()
  4. 3.0.x src/Price.php \Drupal\price\Price::add()

Adds the given price to the current price.

Parameters

\Drupal\price\Price $price: The price.

Return value

static The resulting price.

File

src/Price.php, line 109

Class

Price
Provides a value object for monetary values.

Namespace

Drupal\price

Code

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