You are here

static function RealisticDummyContentEnvironment::FilenameRadical in Realistic Dummy Content 7

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

RealisticDummyContentException

File

api/includes/RealisticDummyContentEnvironment.inc, line 351
Define RealisticDummyContentLiveEnvironment autoload class.

Class

RealisticDummyContentEnvironment
The abstract base environment.

Code

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');
}