*/ /** * 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' => '%0.2f', ); $params = array_merge($parDef, $params); if (!empty($params['money'])) { return sprintf('€' . $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; } }