namespace Prophecy\Call;
use Exception;
+use Prophecy\Argument\ArgumentsWildcard;
/**
* Call object.
private $exception;
private $file;
private $line;
+ private $scores;
/**
* Initializes call.
$this->arguments = $arguments;
$this->returnValue = $returnValue;
$this->exception = $exception;
+ $this->scores = new \SplObjectStorage();
if ($file) {
$this->file = $file;
return sprintf('%s:%d', $this->file, $this->line);
}
+
+ /**
+ * Adds the wildcard match score for the provided wildcard.
+ *
+ * @param ArgumentsWildcard $wildcard
+ * @param false|int $score
+ *
+ * @return $this
+ */
+ public function addScore(ArgumentsWildcard $wildcard, $score)
+ {
+ $this->scores[$wildcard] = $score;
+
+ return $this;
+ }
+
+ /**
+ * Returns wildcard match score for the provided wildcard. The score is
+ * calculated if not already done.
+ *
+ * @param ArgumentsWildcard $wildcard
+ *
+ * @return false|int False OR integer score (higher - better)
+ */
+ public function getScore(ArgumentsWildcard $wildcard)
+ {
+ if (isset($this->scores[$wildcard])) {
+ return $this->scores[$wildcard];
+ }
+
+ return $this->scores[$wildcard] = $wildcard->scoreArguments($this->getArguments());
+ }
}