You are here

public function PriceModified::subtract in Price 3.x

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

Subtracts the given price from the current price.

Parameters

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

Return value

static The resulting price.

File

src/PriceModified.php, line 142

Class

PriceModified
Provides a value object for monetary values.

Namespace

Drupal\price

Code

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