You are here

public function RounderInterface::round in Price 3.x

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

Rounds the given price to its currency precision.

For example, USD prices will be rounded to 2 decimals.

Parameters

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

int $mode: The rounding mode. One of the following constants: PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, PHP_ROUND_HALF_ODD.

Return value

\Drupal\price\Price The rounded price.

Throws

\InvalidArgumentException When given a price with an unknown currency.

1 method overrides RounderInterface::round()
Rounder::round in src/Rounder.php
Rounds the given price to its currency precision.

File

src/RounderInterface.php, line 27

Class

RounderInterface
Rounds prices.

Namespace

Drupal\price

Code

public function round(Price $price, $mode = PHP_ROUND_HALF_UP);