protected function MaskTrait::validateArguments in Image Effects 8.3
Same name and namespace in other branches
- 8 src/Plugin/ImageToolkit/Operation/MaskTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\MaskTrait::validateArguments()
- 8.2 src/Plugin/ImageToolkit/Operation/MaskTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\MaskTrait::validateArguments()
File
- src/Plugin/ImageToolkit/Operation/MaskTrait.php, line 46
Class
- MaskTrait
- Base trait for image_effects Mask operations.
Namespace
Drupal\image_effects\Plugin\ImageToolkit\Operation
Code
protected function validateArguments(array $arguments) {
if (!$arguments['mask_image'] instanceof ImageInterface) {
throw new \InvalidArgumentException("Mask image passed to the 'mask' operation is invalid");
}
if (!$arguments['mask_image']
->isValid()) {
$source = $arguments['mask_image']
->getSource();
throw new \InvalidArgumentException("Invalid image at {$source}");
}
$arguments['mask_width'] = $arguments['mask_width'] !== NULL ? (int) $arguments['mask_width'] : NULL;
if ($arguments['mask_width'] !== NULL && $arguments['mask_width'] <= 0) {
throw new \InvalidArgumentException("Invalid mask width ('{$arguments['mask_width']}') specified for the image 'mask' operation");
}
$arguments['mask_height'] = $arguments['mask_height'] !== NULL ? (int) $arguments['mask_height'] : NULL;
if ($arguments['mask_height'] !== NULL && $arguments['mask_height'] <= 0) {
throw new \InvalidArgumentException("Invalid height ('{$arguments['mask_height']}') specified for the image 'mask' operation");
}
$arguments['x_offset'] = (int) $arguments['x_offset'];
$arguments['y_offset'] = (int) $arguments['y_offset'];
return $arguments;
}