You are here

static function Environment::FilenameRadical in Realistic Dummy Content 8

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

$filename: A filename string, for example 'a.b.txt'

Return value

The name radical of this file, for example a.txt.

Throws

Exception

File

api/src/environments/Environment.php, line 348
Define autoload class.

Class

Environment
The abstract base environment.

Namespace

Drupal\realistic_dummy_content_api\environments

Code

static function FilenameRadical($filename) {
  if (!is_string($filename)) {
    throw new Exception('Please pass ' . __FUNCTION__ . ' a string as a filename, not a ' . gettype($filename));
  }
  return self::Replace($filename, '\\1\\3');
}