3 * This file is part of the PHPUnit_MockObject package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Stubs a method by returning a value from a map.
14 * @since Class available since Release 1.1.0
16 class PHPUnit_Framework_MockObject_Stub_ReturnValueMap implements PHPUnit_Framework_MockObject_Stub
20 public function __construct(array $valueMap)
22 $this->valueMap = $valueMap;
25 public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
27 $parameterCount = count($invocation->parameters);
29 foreach ($this->valueMap as $map) {
30 if (!is_array($map) || $parameterCount != count($map) - 1) {
34 $return = array_pop($map);
35 if ($invocation->parameters === $map) {
43 public function toString()
45 return 'return value from a map';