*/ /** * patTemplate modifier Eval * * Eval PHP interface but for numeric expressions, only * * @package patTemplate * @package Modifiers * @author gERD Schaufelberger */ class patTemplate_Modifier_Eval extends patTemplate_Modifier { /** * Modify the value * * @param string value * @param array $params * @return string modified value */ public function modify($value, $params = array()) { if (!is_array($params)) { $params = array(); } $default = array( 'exp' => '.' ); $params = array_merge($default, $params); if (empty($params['exp'])) { return ''; } $exp = sprintf($params['exp'], $value); return eval('return ('. $exp . ');'); } }