*/ /** * patTemplate modfifier Divide * */ class patTemplate_Modifier_Divide extends patTemplate_Modifier { /** * Modify the Value * * @param string value * @param array attributes * @return string modified value */ public function modify($value, $params = array()) { $defParams = array( 'divisor' => 1, 'zerodivisor' => 'NaN' ); $params = array_merge($defParams, $params); $divisor = floatval($params['divisor']); if (0 == $divisor) { return $params['zerodivisor']; } return $value / $divisor; } }