public function PriceModified::compareTo in Price 3.x
Same name and namespace in other branches
- 8 src/PriceModified.php \Drupal\price\PriceModified::compareTo()
- 3.0.x src/PriceModified.php \Drupal\price\PriceModified::compareTo()
Compares the current price with the given price.
Parameters
\Drupal\price\PriceModified $price: The price.
Return value
int 0 if both prices are equal, 1 if the first one is greater, -1 otherwise.
3 calls to PriceModified::compareTo()
- PriceModified::equals in src/
PriceModified.php - Gets whether the current price is equivalent to the given price.
- PriceModified::greaterThan in src/
PriceModified.php - Gets whether the current price is greater than the given price.
- PriceModified::lessThan in src/
PriceModified.php - Gets whether the current price is lesser than the given price.
File
- src/
PriceModified.php, line 185
Class
- PriceModified
- Provides a value object for monetary values.
Namespace
Drupal\priceCode
public function compareTo(PriceModified $price) {
$this
->assertSameCurrency($this, $price);
return Calculator::compare($this->number, $price
->getNumber());
}