You are here

class ReturnPromise in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpspec/prophecy/src/Prophecy/Promise/ReturnPromise.php \Prophecy\Promise\ReturnPromise

Return promise.

@author Konstantin Kudryashov <ever.zet@gmail.com>

Hierarchy

Expanded class hierarchy of ReturnPromise

File

vendor/phpspec/prophecy/src/Prophecy/Promise/ReturnPromise.php, line 22

Namespace

Prophecy\Promise
View source
class ReturnPromise implements PromiseInterface {
  private $returnValues = array();

  /**
   * Initializes promise.
   *
   * @param array $returnValues Array of values
   */
  public function __construct(array $returnValues) {
    $this->returnValues = $returnValues;
  }

  /**
   * Returns saved values one by one until last one, then continuously returns last value.
   *
   * @param array          $args
   * @param ObjectProphecy $object
   * @param MethodProphecy $method
   *
   * @return mixed
   */
  public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) {
    $value = array_shift($this->returnValues);
    if (!count($this->returnValues)) {
      $this->returnValues[] = $value;
    }
    return $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ReturnPromise::$returnValues private property
ReturnPromise::execute public function Returns saved values one by one until last one, then continuously returns last value. Overrides PromiseInterface::execute
ReturnPromise::__construct public function Initializes promise.