*/ /** * patTemplate modfifier Price * * @package Wombat * @package Modifiers * @author gERD Schaufelberger */ class patTemplate_Modifier_Price extends patTemplate_Modifier { /** * Modify Value * * Format price value * * @param string value * @param array $parameters * @return string modified value */ public function modify($value, $params = array()) { $parDef = array( 'replace00' => '-', 'printf' => '%0.2f', 'money' => '%n', ); $params = array_merge($parDef, $params); if (!empty($params['money'])) { return money_format($params['money'], $value); } $value = sprintf($params['printf'], $value); if (!empty($params['replace00'])) { if ('00' == substr($value, -2)) { $value = substr($value, 0, -2) . $params['replace00']; } } return $value; } }