protected function Identifier::getSnakeCase in Markdown 8.2
Retrieves the snake case variation of the identifier.
Return value
string The snake case variation of the identifier.
2 calls to Identifier::getSnakeCase()
- Identifier::getCamelCase in src/
Annotation/ Identifier.php - Retrieves the camel case variation of the identifier.
- Identifier::getCss in src/
Annotation/ Identifier.php - Retrieves the CSS sanitized variation of the identifier.
File
- src/
Annotation/ Identifier.php, line 181
Class
- Identifier
- Creates an identifier for use in annotation objects.
Namespace
Drupal\markdown\AnnotationCode
protected function getSnakeCase() {
if (!isset($this->snakeCase)) {
// Lowercase identifier.
$this->snakeCase = strtolower($this->value);
// Convert some special characters to double underscores.
$this->snakeCase = preg_replace('/[:\\/\\\\]+/', '__', $this->snakeCase);
// Convert all non-alphanumeric characters to underscores.
$this->snakeCase = preg_replace('/[^a-z0-9_]+/', '_', $this->snakeCase);
// Ensure snake case has no more than two underscores per delimiter.
$this->snakeCase = preg_replace('/__+/', '__', $this->snakeCase);
}
return $this->snakeCase;
}