/** * Processes params (assumed valid) and sets them as class properties * @param Array $params Array of pre-validated params * @param Parser $parser If passed, the parser will be used to recursively parse all params * @return Array An array of processed params */ protected static function processParams($params, $parser = null) { //correct params for compatibility with "HTML Meta and Title" extension foreach (self::$convert_params as $from => $to) { if (isset($params[$from])) { $params[$to] = $params[$from]; unset($params[$from]); } } $processed = array(); //ensure only valid parameter names are processed foreach (self::$valid_params as $p) { if (isset($params[$p])) { //if the parser has been passed and the param is parsable parse it, else simply assign it $processed[$p] = $parser && in_array($p, self::$parse_params) ? $parser->recursiveTagParse($params[$p]) : $params[$p]; } } //set the processed values as class properties foreach ($processed as $k => $v) { if ($k === 'title') { self::$title = $v; } else { if ($k === 'title_mode' && in_array($v, self::$valid_title_modes)) { self::$title_mode = $v; } else { if ($k === 'title_separator') { self::$title_separator = ' ' . $v . ' '; } else { if (isset(self::$tag_types[$k]) && self::$tag_types[$k] === 'meta') { self::$meta[$k] = $v; } else { if (isset(self::$tag_types[$k]) && self::$tag_types[$k] === 'property') { self::$property[$k] = $v; } } } } } } return $processed; }