4 * This file is part of the Prophecy.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 * Marcello Duarte <marcello.duarte@gmail.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Prophecy\Call;
15 use Prophecy\Argument\ArgumentsWildcard;
20 * @author Konstantin Kudryashov <ever.zet@gmail.com>
35 * @param string $methodName
36 * @param array $arguments
37 * @param mixed $returnValue
38 * @param Exception $exception
39 * @param null|string $file
40 * @param null|int $line
42 public function __construct($methodName, array $arguments, $returnValue,
43 Exception $exception = null, $file, $line)
45 $this->methodName = $methodName;
46 $this->arguments = $arguments;
47 $this->returnValue = $returnValue;
48 $this->exception = $exception;
49 $this->scores = new \SplObjectStorage();
53 $this->line = intval($line);
58 * Returns called method name.
62 public function getMethodName()
64 return $this->methodName;
68 * Returns called method arguments.
72 public function getArguments()
74 return $this->arguments;
78 * Returns called method return value.
82 public function getReturnValue()
84 return $this->returnValue;
88 * Returns exception that call thrown.
90 * @return null|Exception
92 public function getException()
94 return $this->exception;
98 * Returns callee filename.
102 public function getFile()
108 * Returns callee line number.
112 public function getLine()
118 * Returns short notation for callee place.
122 public function getCallPlace()
124 if (null === $this->file) {
128 return sprintf('%s:%d', $this->file, $this->line);
132 * Adds the wildcard match score for the provided wildcard.
134 * @param ArgumentsWildcard $wildcard
135 * @param false|int $score
139 public function addScore(ArgumentsWildcard $wildcard, $score)
141 $this->scores[$wildcard] = $score;
147 * Returns wildcard match score for the provided wildcard. The score is
148 * calculated if not already done.
150 * @param ArgumentsWildcard $wildcard
152 * @return false|int False OR integer score (higher - better)
154 public function getScore(ArgumentsWildcard $wildcard)
156 if (isset($this->scores[$wildcard])) {
157 return $this->scores[$wildcard];
160 return $this->scores[$wildcard] = $wildcard->scoreArguments($this->getArguments());