You are here

protected function ImagemagickIdentify::validateKey in ImageMagick 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/FileMetadata/ImagemagickIdentify.php \Drupal\imagemagick\Plugin\FileMetadata\ImagemagickIdentify::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.

3 calls to ImagemagickIdentify::validateKey()
ImagemagickIdentify::doGetMetadata in src/Plugin/FileMetadata/ImagemagickIdentify.php
ImagemagickIdentify::doRemoveMetadata in src/Plugin/FileMetadata/ImagemagickIdentify.php
ImagemagickIdentify::doSetMetadata in src/Plugin/FileMetadata/ImagemagickIdentify.php

File

src/Plugin/FileMetadata/ImagemagickIdentify.php, line 127

Class

ImagemagickIdentify
FileMetadata plugin for ImageMagick's identify results.

Namespace

Drupal\imagemagick\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($key, $this
    ->getSupportedKeys(), TRUE)) {
    throw new FileMetadataException("Invalid metadata key '{$key}' specified", $this
      ->getPluginId(), $method);
  }
  return TRUE;
}