/** * @param string $quantity * @param string|null $unit * @param string $locale */ protected function formatQuantity($quantity, $unit, $locale) { if ($unit === null) { return $this->numberFormatter->format($quantity); } return $this->unitFormatter->format($quantity, $unit === 'hours' ? 'duration-hour' : 'duration-day', 'long', $locale); }
/** * @covers ::format */ public function testExceptionOnInvalidUnit() { $this->setExpectedException('UnexpectedValueException', 'Invalid unit provided: "foobar"'); $formatter = new UnitFormatter('en-US'); $formatter->format(1, 'duration', 'foobar', 'wide'); }