You are here

protected function DrawRectangleTrait::validateArguments in Image Effects 8.2

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

File

src/Plugin/ImageToolkit/Operation/DrawRectangleTrait.php, line 47

Class

DrawRectangleTrait
Base trait for draw rectangle operations.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation

Code

protected function validateArguments(array $arguments) {

  // Ensure 'rectangle' is an expected PositionedRectangle object.
  if (!$arguments['rectangle'] instanceof PositionedRectangle) {
    throw new \InvalidArgumentException("PositionedRectangle passed to the 'draw_rectangle' operation is invalid");
  }

  // Match color luma.
  if ($arguments['fill_color'] && $arguments['fill_color_luma']) {
    $arguments['fill_color'] = ColorUtility::matchLuma($arguments['fill_color']);
  }
  if ($arguments['border_color'] && $arguments['border_color_luma']) {
    $arguments['border_color'] = ColorUtility::matchLuma($arguments['border_color']);
  }
  return $arguments;
}