PhpSpec\Wrapper\Subject\WrappedObject::beConstructedThrough PHP Method

beConstructedThrough() public method

public beConstructedThrough ( callable | string | null $factoryMethod, array $arguments = [] )
$factoryMethod callable | string | null
$arguments array
    public function beConstructedThrough($factoryMethod, array $arguments = array())
    {
        if (is_string($factoryMethod) && false === strpos($factoryMethod, '::') && method_exists($this->classname, $factoryMethod)) {
            $factoryMethod = array($this->classname, $factoryMethod);
        }
        if ($this->isInstantiated()) {
            throw new SubjectException('You can not change object construction method when it is already instantiated');
        }
        $this->factoryMethod = $factoryMethod;
        $unwrapper = new Unwrapper();
        $this->arguments = $unwrapper->unwrapAll($arguments);
    }

Usage Example

Esempio n. 1
0
 /**
  * @param array|string $factoryMethod
  * @param array        $arguments
  */
 public function beConstructedThrough($factoryMethod, array $arguments = array())
 {
     $this->wrappedObject->beConstructedThrough($factoryMethod, $arguments);
 }