locale's code (simplified IETF tag syntax) * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) * eg: fr-FR, en-US. * * @return string */ public function getCode() { return $this->code; } /** * Format a number according to locale rules. * * @param int|float|string $number * The number to be formatted * * @return string * The formatted number * * @throws Exception\LocalizationException */ public function formatNumber($number) { return $this->numberFormatter->format( $number, $this->numberSpecification ); } /** * Format a number as a price. * * @param int|float|string $number * Number to be formatted as a price * @param string $currencyCode * Currency of the price * * @return string The formatted price * * @throws Exception\LocalizationException */ public function formatPrice($number, $currencyCode) { return $this->numberFormatter->format( $number, $this->getPriceSpecification($currencyCode) ); } /** * Get price specification * * @param string $currencyCode Currency of the price * * @return NumberSpecificationInterface */ public function getPriceSpecification($currencyCode) { $currencyCode = (string) $currencyCode; $priceSpec = $this->priceSpecifications->get($currencyCode); if (null === $priceSpec) { throw new LocalizationException('Price specification not found for currency: "' . $currencyCode . '"'); } return $priceSpec; } /** * Get number specification * * @return NumberSpecification */ public function getNumberSpecification() { return $this->numberSpecification; } }