protected function EasyRdf_Serialiser_GraphViz::escape

Internal function to escape a string into DOT safe syntax

@ignore

3 calls to EasyRdf_Serialiser_GraphViz::escape()
EasyRdf_Serialiser_GraphViz::escapeAttributes in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/GraphViz.php
Internal function to escape an associate array of attributes and turns it into a DOT notation string
EasyRdf_Serialiser_GraphViz::serialiseDot in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/GraphViz.php
Internal function to serialise an EasyRdf_Graph into a DOT formatted string
EasyRdf_Serialiser_GraphViz::serialiseRow in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/GraphViz.php
Internal function to create dot syntax line for either a node or an edge

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/GraphViz.php, line 203

Class

EasyRdf_Serialiser_GraphViz
Class to serialise an EasyRdf_Graph to GraphViz

Code

protected function escape($input) {
  if (preg_match('/^([a-z_][a-z_0-9]*|-?(\\.[0-9]+|[0-9]+(\\.[0-9]*)?))$/i', $input)) {
    return $input;
  }
  else {
    return '"' . str_replace(array(
      "\r\n",
      "\n",
      "\r",
      '"',
    ), array(
      '\\n',
      '\\n',
      '\\n',
      '\\"',
    ), $input) . '"';
  }
}