Пример #1
0
 /**
  * @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);
 }
Пример #2
0
 /**
  * @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());
 }
Пример #3
0
 /**
  * @return object
  */
 private function makeSureWeHaveASubject()
 {
     if (null === $this->subject && $this->wrappedObject->getClassname()) {
         $instantiator = new Instantiator();
         return $instantiator->instantiate($this->wrappedObject->getClassname());
     }
     return $this->subject;
 }