You are here

protected function ContrastTrait::validateArguments in Image Effects 8

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

File

src/Plugin/ImageToolkit/Operation/ContrastTrait.php, line 24

Class

ContrastTrait
Base trait for image_effects Contrast operations.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation

Code

protected function validateArguments(array $arguments) {

  // Assure contrast level is valid.
  if (!is_numeric($arguments['level']) || !is_int($arguments['level'] + 5) || $arguments['level'] < -100 || $arguments['level'] > 100) {
    throw new \InvalidArgumentException("Invalid level ('{$arguments['level']}') specified for the image 'contrast' operation");
  }
  return $arguments;
}