You are here

public function Price::subtract in Price 3.0.x

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

Subtracts the given price from the current price.

Parameters

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

Return value

static The resulting price.

File

src/Price.php, line 124

Class

Price
Provides a value object for monetary values.

Namespace

Drupal\price

Code

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