You are here

public function ImagemagickExecArguments::findArgument in ImageMagick 8.2

Finds if a command line argument exists.

Parameters

string $arg: The command line argument to be found.

Return value

bool Returns the array key for the argument if it is found in the array, FALSE otherwise.

Deprecated

in 8.x-2.3, will be removed in 8.x-3.0. Use ::find() instead.

See also

https://www.drupal.org/project/imagemagick/issues/2925780

File

src/ImagemagickExecArguments.php, line 270

Class

ImagemagickExecArguments
Stores arguments for execution of ImageMagick/GraphicsMagick commands.

Namespace

Drupal\imagemagick

Code

public function findArgument($arg) {
  @trigger_error('findArgument() is deprecated in 8.x-2.3, will be removed in 8.x-3.0. Use ::find() instead. See https://www.drupal.org/project/imagemagick/issues/2925780.', E_USER_DEPRECATED);
  if (strpos($arg, self::INTERNAL_ARGUMENT_IDENTIFIER) === 0) {
    @trigger_error('Adding internal arguments prefixing them with ImagemagickExecArguments::INTERNAL_ARGUMENT_IDENTIFIER is deprecated in 8.x-2.3, will be removed in 8.x-3.0. ::add() them with ImageMagickExecArguments::INTERNAL instead. See https://www.drupal.org/project/imagemagick/issues/2925780.', E_USER_DEPRECATED);
    foreach ($this
      ->getArguments() as $i => $a) {
      if (strpos($a, $arg) === 0) {
        return $i;
      }
    }
    return FALSE;
  }
  $matches = $this
    ->find('/^' . preg_quote($arg, '/') . '/', self::POST_SOURCE);
  if (!empty($matches)) {
    $keys = array_keys($matches);
    return $keys[0];
  }
  return FALSE;
}