You are here

public static function RealisticDummyContentEnvironment::attributeName in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::attributeName()
  2. 7.2 api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::attributeName()

Returns the attribute of a filename if one exists.

If >2 periods are present in the file name, then what is between the last and next to last period is kept, for example:

a.b.c => b a.b.c.d => c a.b => NULL a => NULL

Parameters

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

Return value

null|string Null if there is attribute to extract; otherwise the attribute name, for example "b".

Throws

\Exception

File

api/src/includes/RealisticDummyContentEnvironment.php, line 323

Class

RealisticDummyContentEnvironment
The abstract base environment.

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public static function attributeName($filename) {
  $replaced = self::replace($filename, '\\2');
  if ($replaced != $filename) {
    return $replaced;
  }
  else {
    return NULL;
  }
}