original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Replaces the data with the template variables configured on this instance .