You are here

protected function OpacityTrait::validateArguments in Image Effects 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/Operation/OpacityTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\OpacityTrait::validateArguments()
  2. 8 src/Plugin/ImageToolkit/Operation/OpacityTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\OpacityTrait::validateArguments()

File

src/Plugin/ImageToolkit/Operation/OpacityTrait.php, line 26

Class

OpacityTrait
Base trait for image_effects Opacity operations.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation

Code

protected function validateArguments(array $arguments) {

  // Ensure opacity is in the range 0-100.
  if (!is_numeric($arguments['opacity']) || $arguments['opacity'] > 100 || $arguments['opacity'] < 0) {
    throw new \InvalidArgumentException("Invalid opacity ('{$arguments['opacity']}') specified for the image 'opacity' operation");
  }
  return $arguments;
}