public function testFormattingWithArrayOptions() { $interval = 14400 * 1000; $class = new Duration($interval); $format = ['template' => '{hours} {minutes} {seconds}', '{hours}' => '{hours} hours', '{minutes}' => '{minutes} minutes', '{seconds}' => '{seconds} seconds']; $actual = $class->format($format); $hours = floor($interval / (1000 * 60 * 60)); $left = $interval % (1000 * 60 * 60); $minutes = floor($left / (1000 * 60)); $left = $interval % (1000 * 60); $seconds = floor($left / 1000); $result = '4 hours'; $this->assertEquals($result, $actual); }
public function duration() { $duration = new Duration(intval($this->wrappedObject->duration()) * 60000); $format = ['template' => '{hours} {minutes} {seconds}', '{hours}' => '{hours} hours', '{minutes}' => '{minutes} minutes', '{seconds}' => '{seconds} seconds']; return $duration->format($format); }