Esempio n. 1
0
 /**
  * Ensure that the request contains valid options
  *
  * @param array $options
  * @return array
  */
 private function validateOptions(array $options)
 {
     $required_options = ['width' => 'is_numeric', 'height' => 'is_numeric'];
     foreach ($required_options as $required => $validator) {
         if (!array_key_exists($required, $options) || is_null($options[$required]) || !$validator($options[$required])) {
             http_response_code(400);
             throw new InvalidArgumentException("The {$required} parameter is missing or invalid.");
         }
     }
     $options['format'] = $this->getOptionsKey($options, 'format', $this->file->getExtension());
     $options['crop'] = $this->getOptionsKey($options, 'crop', false);
     $options['min_quality'] = $this->getOptionsKey($options, 'min_quality', self::FULL_COMPRESSION);
     $options['max_quality'] = $this->getOptionsKey($options, 'max_quality', self::NO_COMPRESSION);
     $options['max_file_size_bytes'] = $this->getOptionsKey($options, 'max_file_size_bytes', false);
     return $options;
 }