protected function createStub($name)
{
$isMagic = !$this->class->hasMethod($name);
$callMagicMethod = $this->callMagicMethod;
if ($isMagic && !$callMagicMethod) {
throw new UndefinedMethodStubException($this->class->getName(), $name);
}
$mock = $this->mock;
$key = strtolower($name);
if ($isMagic) {
if ($mock) {
$magicKey = '__call';
} else {
$magicKey = '__callstatic';
}
$stub = $this->stubFactory->create(new WrappedMagicMethod($name, $this->callMagicMethod, isset($this->uncallableMethods[$magicKey]), $this), $mock, $this->state->defaultAnswerCallback);
} elseif (isset($this->uncallableMethods[$key])) {
$stub = $this->stubFactory->create(new WrappedUncallableMethod($this->class->getMethod($name), $this), $mock, $this->state->defaultAnswerCallback);
} elseif (isset($this->traitMethods[$key])) {
$stub = $this->stubFactory->create(new WrappedTraitMethod($this->callTraitMethod, $this->traitMethods[$key], $this->class->getMethod($name), $this), $mock, $this->state->defaultAnswerCallback);
} elseif (array_key_exists($key, $this->customMethods)) {
$stub = $this->stubFactory->create(new WrappedCustomMethod($this->customMethods[$key], $this->class->getMethod($name), $this, $this->invoker), $mock, $this->state->defaultAnswerCallback);
} else {
$method = $this->class->getMethod($name);
if ($method->isFinal()) {
throw new FinalMethodStubException($this->class->getName(), $name);
}
$stub = $this->stubFactory->create(new WrappedParentMethod($this->callParentMethod, $method, $this), $mock, $this->state->defaultAnswerCallback);
}
$stubVerifier = $this->stubVerifierFactory->create($stub);
if (!$this->state->isRecording) {
$stubVerifier->stopRecording();
}
return $stubVerifier;
}