Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / phpspec / prophecy / src / Prophecy / Call / Call.php
index 2f3fbadb1a6d8006f51aa8f4c0a410959a553725..2652235453ded23b0910dff6bf5f69b7a76dbacb 100644 (file)
@@ -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());
+    }
 }