X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fphpspec%2Fprophecy%2Fsrc%2FProphecy%2FCall%2FCall.php;h=2652235453ded23b0910dff6bf5f69b7a76dbacb;hp=2f3fbadb1a6d8006f51aa8f4c0a410959a553725;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/phpspec/prophecy/src/Prophecy/Call/Call.php b/vendor/phpspec/prophecy/src/Prophecy/Call/Call.php index 2f3fbadb1..265223545 100644 --- a/vendor/phpspec/prophecy/src/Prophecy/Call/Call.php +++ b/vendor/phpspec/prophecy/src/Prophecy/Call/Call.php @@ -12,6 +12,7 @@ namespace Prophecy\Call; use Exception; +use Prophecy\Argument\ArgumentsWildcard; /** * Call object. @@ -26,6 +27,7 @@ class Call private $exception; private $file; private $line; + private $scores; /** * Initializes call. @@ -44,6 +46,7 @@ class Call $this->arguments = $arguments; $this->returnValue = $returnValue; $this->exception = $exception; + $this->scores = new \SplObjectStorage(); if ($file) { $this->file = $file; @@ -124,4 +127,36 @@ class Call 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()); + } }