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

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

Create a new static handle.
public staticHandle ( Eloquent\Phony\Mock\Mock | Eloquent\Phony\Mock\Handle\Handle | ReflectionClas\ReflectionClass | string $class ) : StaticHandle
$class Eloquent\Phony\Mock\Mock | Eloquent\Phony\Mock\Handle\Handle | ReflectionClas\ReflectionClass | string The class.
Результат StaticHandle The newly created handle.
    public function staticHandle($class)
    {
        if ($class instanceof StaticHandle) {
            return $class;
        }
        if ($class instanceof Handle) {
            $class = $class->clazz();
        } elseif ($class instanceof Mock) {
            $class = new ReflectionClass($class);
        } elseif (is_string($class)) {
            try {
                $class = new ReflectionClass($class);
            } catch (ReflectionException $e) {
                throw new NonMockClassException($class, $e);
            }
        } elseif (!$class instanceof ReflectionClass) {
            throw new InvalidMockClassException($class);
        }
        if (!$class->isSubclassOf('Eloquent\\Phony\\Mock\\Mock')) {
            throw new NonMockClassException($class->getName());
        }
        $handleProperty = $class->getProperty('_staticHandle');
        $handleProperty->setAccessible(true);
        if ($handle = $handleProperty->getValue(null)) {
            return $handle;
        }
        $handle = new StaticHandle($class, (object) array('defaultAnswerCallback' => 'Eloquent\\Phony\\Stub\\StubData::forwardsAnswerCallback', 'stubs' => (object) array(), 'isRecording' => true), $this->stubFactory, $this->stubVerifierFactory, $this->assertionRenderer, $this->assertionRecorder, $this->invoker);
        $handleProperty->setValue(null, $handle);
        return $handle;
    }