PhpSpec\Wrapper\Subject\Caller::getWrappedObject PHP Method

getWrappedObject() public method

public getWrappedObject ( ) : object
return object
    public function getWrappedObject()
    {
        if ($this->wrappedObject->isInstantiated()) {
            return $this->wrappedObject->getInstance();
        }
        if (null === $this->wrappedObject->getClassName() || !is_string($this->wrappedObject->getClassName())) {
            return $this->wrappedObject->getInstance();
        }
        if (!class_exists($this->wrappedObject->getClassName())) {
            throw $this->classNotFound();
        }
        if (is_object($this->wrappedObject->getInstance())) {
            $this->wrappedObject->setInstantiated(true);
            $instance = $this->wrappedObject->getInstance();
        } else {
            $instance = $this->instantiateWrappedObject();
            $this->wrappedObject->setInstance($instance);
            $this->wrappedObject->setInstantiated(true);
        }
        return $instance;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @return mixed
  */
 public function getWrappedObject()
 {
     if ($this->subject) {
         return $this->subject;
     }
     return $this->subject = $this->caller->getWrappedObject();
 }
All Usage Examples Of PhpSpec\Wrapper\Subject\Caller::getWrappedObject