You are here

protected function ConvolutionTrait::validateArguments in Image Effects 8.3

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

File

src/Plugin/ImageToolkit/Operation/ConvolutionTrait.php, line 30

Class

ConvolutionTrait
Base trait for image_effects Convolution operations.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation

Code

protected function validateArguments(array $arguments) {

  // Ensure convolution parameters are valid.
  foreach ($arguments['kernel'] as $row) {
    foreach ($row as $kernel_entry) {
      if (!is_numeric($kernel_entry)) {
        throw new \InvalidArgumentException("Invalid kernel entry ('{$arguments['divisor']}') specified for the image 'convolution' operation");
      }
    }
  }
  if (!is_numeric($arguments['divisor'])) {
    throw new \InvalidArgumentException("Invalid divisor ('{$arguments['divisor']}') specified for the image 'convolution' operation");
  }
  if (!is_numeric($arguments['offset'])) {
    throw new \InvalidArgumentException("Invalid offset ('{$arguments['offset']}') specified for the image 'convolution' operation");
  }
  return $arguments;
}