public static function RealisticDummyContentEnvironment::filenameRadical in Realistic Dummy Content 7.2
Same name and namespace in other branches
- 8.2 api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::filenameRadical()
- 3.x api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::filenameRadical()
Returns the name radical of a filename.
The following examples will all return "two.txt"
two.txt two.txt.attribute.txt two.txt.attribute1.txt
If >2 periods are present in the file name, then what is between the last and next to last period is removed, for example:
a.b.c => a.c a.b.c.d => a.b.d a.b => a.b a => a
Parameters
string $filename: A filename string, for example 'a.b.txt'.
Return value
string The name radical of this file, for example a.txt.
Throws
RealisticDummyContentException
File
- api/
src/ includes/ RealisticDummyContentEnvironment.php, line 370
Class
- RealisticDummyContentEnvironment
- The abstract base environment.
Namespace
Drupal\realistic_dummy_content_api\includesCode
public static function filenameRadical($filename) {
if (!is_string($filename)) {
throw new RealisticDummyContentException('Please pass ' . __FUNCTION__ . ' a string as a filename, not a ' . gettype($filename));
}
return self::replace($filename, '\\1\\3');
}