/** * @param string $method * @param array $arguments * * @return mixed */ public function during($method, array $arguments = array()) { if ($method === '__construct') { $this->subject->beAnInstanceOf($this->wrappedObject->getClassname(), $arguments); $instantiator = new Instantiator(); $object = $instantiator->instantiate($this->wrappedObject->getClassname()); } else { $object = $this->wrappedObject->instantiate(); } return $this->runDuring($object, $method, $arguments); }
/** * @return mixed */ public function duringInstantiation() { if ($factoryMethod = $this->wrappedObject->getFactoryMethod()) { $method = is_array($factoryMethod) ? $factoryMethod[1] : $factoryMethod; } else { $method = '__construct'; } $instantiator = new Instantiator(); $object = $instantiator->instantiate($this->wrappedObject->getClassname()); return $this->runDuring($object, $method, $this->wrappedObject->getArguments()); }
/** * @return object */ private function makeSureWeHaveASubject() { if (null === $this->subject && $this->wrappedObject->getClassname()) { $instantiator = new Instantiator(); return $instantiator->instantiate($this->wrappedObject->getClassname()); } return $this->subject; }