class ReturnArgumentPromise in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Promise/ReturnArgumentPromise.php \Prophecy\Promise\ReturnArgumentPromise
Return argument promise.
@author Konstantin Kudryashov <ever.zet@gmail.com>
Hierarchy
- class \Prophecy\Promise\ReturnArgumentPromise implements PromiseInterface
Expanded class hierarchy of ReturnArgumentPromise
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Promise/ ReturnArgumentPromise.php, line 23
Namespace
Prophecy\PromiseView source
class ReturnArgumentPromise implements PromiseInterface {
/**
* @var int
*/
private $index;
/**
* Initializes callback promise.
*
* @param int $index The zero-indexed number of the argument to return
*
* @throws \Prophecy\Exception\InvalidArgumentException
*/
public function __construct($index = 0) {
if (!is_int($index) || $index < 0) {
throw new InvalidArgumentException('Zero-based index expected as argument to ReturnArgumentPromise, but got %s.', $index);
}
$this->index = $index;
}
/**
* Returns nth argument if has one, null otherwise.
*
* @param array $args
* @param ObjectProphecy $object
* @param MethodProphecy $method
*
* @return null|mixed
*/
public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) {
return count($args) > $this->index ? $args[$this->index] : null;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ReturnArgumentPromise:: |
private | property | ||
ReturnArgumentPromise:: |
public | function |
Returns nth argument if has one, null otherwise. Overrides PromiseInterface:: |
|
ReturnArgumentPromise:: |
public | function | Initializes callback promise. |