labelSecondsPlural = $labelSecondsPlural; } /** * Beautifies and returns a range label whose range spans over one unit, ie * 1-1, 2-2 or 3-3. * * If the lower bound of the range is less than 60 the pretty range label * will be in seconds. Otherwise, it will be in minutes. * * @param string $oldLabel The original label value. * @param int $lowerBound The lower bound of the range. * @return string The pretty range label. */ public function getSingleUnitLabel($oldLabel, $lowerBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound, $lowerBound); } else if ($lowerBound == 60) { return $this->labelSingular; } else { return sprintf($this->labelPlural, ceil($lowerBound / 60)); } } /** * Beautifies and returns a range label whose range is bounded and spans over * more than one unit, ie 1-5, 5-10 but NOT 11+. * * If the lower bound of the range is less than 60 the pretty range label * will be in seconds. Otherwise, it will be in minutes. * * @param string $oldLabel The original label value. * @param int $lowerBound The lower bound of the range. * @param int $upperBound The upper bound of the range. * @return string The pretty range label. */ public function getRangeLabel($oldLabel, $lowerBound, $upperBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound, $upperBound); } else { return sprintf($this->labelPlural, ceil($lowerBound / 60) . "-" . ceil($upperBound / 60)); } } /** * Beautifies and returns a range label whose range is unbounded, ie * 5+, 10+, etc. * * If the lower bound of the range is less than 60 the pretty range label * will be in seconds. Otherwise, it will be in minutes. * * @param string $oldLabel The original label value. * @param int $lowerBound The lower bound of the range. * @return string The pretty range label. */ public function getUnboundedLabel($oldLabel, $lowerBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound); } else { // since we're using minutes, we use floor so 1801s+ will be 30m+ and not 31m+ return sprintf($this->labelPlural, "" . floor($lowerBound / 60) . urlencode('+')); } } }