public function replaceTemplateVariables($data)
    {
        $this->assertDataIsWritable();

        if ($templateVariables = $this->getOption('templateVariables', [])) {
            $templateVariableKeys = array_keys($templateVariables);

            if (is_string($data)) {
                $data = str_replace($templateVariableKeys, $templateVariables, $data);
            } else if (is_array($data)) {
                array_walk_recursive(
                    $data,
                    function(&$value, &$key, &$data) {
                        $value = str_replace($data['keys'], $data['values'], $value);
                    },
                    [
                        'keys'      => $templateVariableKeys,
                        'values'    => $templateVariables
                    ]
                );
            }
        }

        return $data;
    }
public function replaceTemplateVariables($data)
    {
        $this->assertDataIsWritable();

        if ($templateVariables = $this->getOption('templateVariables', [])) {
            $templateVariableKeys = array_keys($templateVariables);

            if (is_string($data)) {
                $data = str_replace($templateVariableKeys, $templateVariables, $data);
            } else if (is_array($data)) {
                array_walk_recursive(
                    $data,
                    function(&$value, &$key, &$data) {
                        $value = str_replace($data['keys'], $data['values'], $value);
                    },
                    [
                        'keys'      => $templateVariableKeys,
                        'values'    => $templateVariables
                    ]
                );
            }
        }

        return $data;
    }
public function replaceTemplateVariables ( $ data ) { $ this -> assertDataIsWritable ( ) ; if ( $ templateVariables = $ this -> getOption ( 'templateVariables' , [ ] ) ) { $ templateVariableKeys = array_keys ( $ templateVariables ) ; if ( is_string ( $ data ) ) { $ data = str_replace ( $ templateVariableKeys , $ templateVariables , $ data ) ; } else if ( is_array ( $ data ) ) { array_walk_recursive ( $ data , function ( & $ value , & $ key , & $ data ) { $ value = str_replace ( $ data [ 'keys' ] , $ data [ 'values' ] , $ value ) ; } , [ 'keys' => $ templateVariableKeys , 'values' => $ templateVariables ] ) ; } } return $ data ; }
Replaces the data with the template variables configured on this instance.

@param string|array $data - Data.

@throws DataIsReadOnlyException - If data is on read-only status.

@return string|array
Replaces the data with the template variables configured on this instance .