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\Promise;
14 use Prophecy\Prophecy\ObjectProphecy;
15 use Prophecy\Prophecy\MethodProphecy;
20 * @author Konstantin Kudryashov <ever.zet@gmail.com>
22 class ReturnPromise implements PromiseInterface
24 private $returnValues = array();
27 * Initializes promise.
29 * @param array $returnValues Array of values
31 public function __construct(array $returnValues)
33 $this->returnValues = $returnValues;
37 * Returns saved values one by one until last one, then continuously returns last value.
40 * @param ObjectProphecy $object
41 * @param MethodProphecy $method
45 public function execute(array $args, ObjectProphecy $object, MethodProphecy $method)
47 $value = array_shift($this->returnValues);
49 if (!count($this->returnValues)) {
50 $this->returnValues[] = $value;