You are here

public function ArgumentsWildcard::scoreArguments in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Argument/ArgumentsWildcard.php \Prophecy\Argument\ArgumentsWildcard::scoreArguments()

Calculates wildcard match score for provided arguments.

Parameters

array $arguments:

Return value

false|int False OR integer score (higher - better)

File

vendor/phpspec/prophecy/src/Prophecy/Argument/ArgumentsWildcard.php, line 50

Class

ArgumentsWildcard
Arguments wildcarding.

Namespace

Prophecy\Argument

Code

public function scoreArguments(array $arguments) {
  if (0 == count($arguments) && 0 == count($this->tokens)) {
    return 1;
  }
  $arguments = array_values($arguments);
  $totalScore = 0;
  foreach ($this->tokens as $i => $token) {
    $argument = isset($arguments[$i]) ? $arguments[$i] : null;
    if (1 >= ($score = $token
      ->scoreArgument($argument))) {
      return false;
    }
    $totalScore += $score;
    if (true === $token
      ->isLast()) {
      return $totalScore;
    }
  }
  if (count($arguments) > count($this->tokens)) {
    return false;
  }
  return $totalScore;
}