You are here

trait ColorshiftTrait in Image Effects 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/Operation/ColorshiftTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\ColorshiftTrait
  2. 8 src/Plugin/ImageToolkit/Operation/ColorshiftTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\ColorshiftTrait

Base trait for image_effects Colorshift operations.

Hierarchy

2 files declare their use of ColorshiftTrait
Colorshift.php in src/Plugin/ImageToolkit/Operation/gd/Colorshift.php
Colorshift.php in src/Plugin/ImageToolkit/Operation/imagemagick/Colorshift.php

File

src/Plugin/ImageToolkit/Operation/ColorshiftTrait.php, line 10

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation
View source
trait ColorshiftTrait {

  /**
   * {@inheritdoc}
   */
  protected function arguments() {
    return [
      'RGB' => [
        'description' => 'The RGB of the color shift.',
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function validateArguments(array $arguments) {

    // Assure color is a valid hex string.
    if (!Color::validateHex($arguments['RGB'])) {
      throw new \InvalidArgumentException("Invalid color ('{$arguments['RGB']}') specified for the image 'colorshift' operation");
    }
    return $arguments;
  }

}

Members