You are here

public function ImagemagickExecArguments::find in ImageMagick 8.2

Same name and namespace in other branches
  1. 8.3 src/ImagemagickExecArguments.php \Drupal\imagemagick\ImagemagickExecArguments::find()

Returns an array of the indexes of arguments matching specific criteria.

Parameters

string $regex: The regular expression pattern to be matched in the argument.

int $mode: (optional) If set, limits the search to the mode of the argument. Defaults to NULL.

array $info: (optional) If set, limits the search to the arguments whose $info array key/values match the key/values specified. Defaults to an empty array.

Return value

array Returns an array with the matching arguments.

1 call to ImagemagickExecArguments::find()
ImagemagickExecArguments::findArgument in src/ImagemagickExecArguments.php
Finds if a command line argument exists.

File

src/ImagemagickExecArguments.php, line 304

Class

ImagemagickExecArguments
Stores arguments for execution of ImageMagick/GraphicsMagick commands.

Namespace

Drupal\imagemagick

Code

public function find($regex, $mode = NULL, array $info = []) {
  $ret = [];
  foreach ($this->arguments as $i => $a) {
    if ($mode !== NULL && $a['mode'] !== $mode) {
      continue;
    }
    if (!empty($info)) {
      $intersect = array_intersect($info, $a['info']);
      if ($intersect != $info) {
        continue;
      }
    }
    if (preg_match($regex, $a['argument']) === 1) {
      $ret[$i] = $a;
    }
  }
  return $ret;
}