class CallbackPrediction in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Prediction/CallbackPrediction.php \Prophecy\Prediction\CallbackPrediction
Callback prediction.
@author Konstantin Kudryashov <ever.zet@gmail.com>
Hierarchy
- class \Prophecy\Prediction\CallbackPrediction implements PredictionInterface
Expanded class hierarchy of CallbackPrediction
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Prediction/ CallbackPrediction.php, line 25
Namespace
Prophecy\PredictionView source
class CallbackPrediction implements PredictionInterface {
private $callback;
/**
* Initializes callback prediction.
*
* @param callable $callback Custom callback
*
* @throws \Prophecy\Exception\InvalidArgumentException
*/
public function __construct($callback) {
if (!is_callable($callback)) {
throw new InvalidArgumentException(sprintf('Callable expected as an argument to CallbackPrediction, but got %s.', gettype($callback)));
}
$this->callback = $callback;
}
/**
* Executes preset callback.
*
* @param Call[] $calls
* @param ObjectProphecy $object
* @param MethodProphecy $method
*/
public function check(array $calls, ObjectProphecy $object, MethodProphecy $method) {
$callback = $this->callback;
if ($callback instanceof Closure && method_exists('Closure', 'bind')) {
$callback = Closure::bind($callback, $object);
}
call_user_func($callback, $calls, $object, $method);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CallbackPrediction:: |
private | property | ||
CallbackPrediction:: |
public | function |
Executes preset callback. Overrides PredictionInterface:: |
|
CallbackPrediction:: |
public | function | Initializes callback prediction. |