function ThrowPromise::execute
Overrides PromiseInterface::execute
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Promise/ ThrowPromise.php, line 62
Class
- ThrowPromise
- Throws predefined exception.
Namespace
Prophecy\PromiseCode
public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) {
if (is_string($this->exception)) {
$classname = $this->exception;
$reflection = new ReflectionClass($classname);
$constructor = $reflection->getConstructor();
if ($constructor === null || $constructor->isPublic() && 0 == $constructor->getNumberOfRequiredParameters()) {
throw $reflection->newInstance();
}
if (!$this->instantiator) {
$this->instantiator = new Instantiator();
}
throw $this->instantiator
->instantiate($classname);
}
throw $this->exception;
}