Eloquent\Phony\Mock\Handle\HandleFactory::instanceHandle PHP Метод

instanceHandle() публичный Метод

Create a new handle.
public instanceHandle ( Eloquent\Phony\Mock\Mock | InstanceHandle $mock, string | null $label = null ) : InstanceHandle
$mock Eloquent\Phony\Mock\Mock | InstanceHandle The mock.
$label string | null The label.
Результат InstanceHandle The newly created handle.
    public function instanceHandle($mock, $label = null)
    {
        if ($mock instanceof InstanceHandle) {
            return $mock;
        }
        if (!$mock instanceof Mock) {
            throw new InvalidMockException($mock);
        }
        $class = new ReflectionClass($mock);
        $handleProperty = $class->getProperty('_handle');
        $handleProperty->setAccessible(true);
        $handle = @$handleProperty->getValue($mock);
        if ($handle) {
            return $handle;
        }
        $handle = new InstanceHandle($mock, (object) array('defaultAnswerCallback' => 'Eloquent\\Phony\\Stub\\StubData::returnsEmptyAnswerCallback', 'stubs' => (object) array(), 'isRecording' => true, 'label' => $label), $this->stubFactory, $this->stubVerifierFactory, $this->assertionRenderer, $this->assertionRecorder, $this->invoker);
        @$handleProperty->setValue($mock, $handle);
        return $handle;
    }