You are here

protected function Font::validateKey in File metadata manager 8

Same name and namespace in other branches
  1. 8.2 file_mdm_font/src/Plugin/FileMetadata/Font.php \Drupal\file_mdm_font\Plugin\FileMetadata\Font::validateKey()

Validates a file metadata key.

Return value

bool TRUE if the key is valid.

Throws

\Drupal\file_mdm\FileMetadataException In case the key is invalid.

1 call to Font::validateKey()
Font::doGetMetadata in file_mdm_font/src/Plugin/FileMetadata/Font.php
Gets a metadata element.

File

file_mdm_font/src/Plugin/FileMetadata/Font.php, line 72

Class

Font
FileMetadata plugin for TTF/OTF/WOFF font information.

Namespace

Drupal\file_mdm_font\Plugin\FileMetadata

Code

protected function validateKey($key, $method) {
  if (!is_string($key)) {
    throw new FileMetadataException("Invalid metadata key specified", $this
      ->getPluginId(), $method);
  }
  if (!in_array(strtolower($key), array_map('strtolower', $this
    ->getSupportedKeys()), TRUE)) {
    throw new FileMetadataException("Invalid metadata key '{$key}' specified", $this
      ->getPluginId(), $method);
  }
  return TRUE;
}