You are here

trait BrightnessTrait in Image Effects 8.3

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

Base trait for image_effects Brightness operations.

Hierarchy

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

File

src/Plugin/ImageToolkit/Operation/BrightnessTrait.php, line 8

Namespace

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

  /**
   * {@inheritdoc}
   */
  protected function arguments() {
    return [
      'level' => [
        'description' => 'The brightness level.',
      ],
    ];
  }

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

    // Assure brightness 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 'brightness' operation");
    }
    return $arguments;
  }

}

Members