public function execute(array $args, FunctionProphecy $function)
    {
        if (is_string($this->exception)) {
            $classname = $this->exception;
            $reflection = new ReflectionClass($classname);
            $constructor = $reflection->getConstructor();

            if ($constructor->isPublic() && 0 == $constructor->getNumberOfRequiredParameters()) {
                throw $reflection->newInstance();
            }

            if (!$this->instantiator) {
                $this->instantiator = new Instantiator();
            }

            throw $this->instantiator->instantiate($classname);
        }

        throw $this->exception;
    }
public function execute(array $args, FunctionProphecy $function)
    {
        if (is_string($this->exception)) {
            $classname = $this->exception;
            $reflection = new ReflectionClass($classname);
            $constructor = $reflection->getConstructor();

            if ($constructor->isPublic() && 0 == $constructor->getNumberOfRequiredParameters()) {
                throw $reflection->newInstance();
            }

            if (!$this->instantiator) {
                $this->instantiator = new Instantiator();
            }

            throw $this->instantiator->instantiate($classname);
        }

        throw $this->exception;
    }
public function execute ( array $ args , FunctionProphecy $ function ) { if ( is_string ( $ this -> exception ) ) { $ classname = $ this -> exception ; $ reflection = new ReflectionClass ( $ classname ) ; $ constructor = $ reflection -> getConstructor ( ) ; if ( $ constructor -> isPublic ( ) && 0 == $ constructor -> getNumberOfRequiredParameters ( ) ) { throw $ reflection -> newInstance ( ) ; } if ( ! $ this -> instantiator ) { $ this -> instantiator = new Instantiator ( ) ; } throw $ this -> instantiator -> instantiate ( $ classname ) ; } throw $ this -> exception ; }
Throws predefined exception.

@param array          $args
@param FunctionProphecy $function

@throws object
Throws predefined exception .