/**
  * Wire the dependencies provided to the object, returning the
  * instantiated object.
  * 
  * Get the provider instance from the dependency list and run the
  * {@see ProviderInterface::get()} method.
  * 
  * @throws RuntimeException When the provider instance doesn't
  *         implement ProviderInterface, also when the provider
  *         doesn't return the appropriate class.
  * @param DependencyList $dependencyList The dependency list of
  *        this class, with all dependencies fulfilled.
  * @return mixed The object that this injector is supposed to
  *         instantiate.
  *
  */
 public function inject(DependencyList $dependencyList)
 {
     $provider = $dependencyList->getInstantiatedDependency($this->providerReference);
     if ($provider instanceof ProviderInterface == FALSE) {
         $id = $this->reference->getID();
         throw new RuntimeException("ProviderClassInjector error when trying to instantiate '{$id}'. The provider object does not implement Carrot\\DependencyInjection\\Injector\\ProviderInterface.");
     }
     $object = $provider->get();
     return $object;
 }
 /**
  * Checks if this object is identical to the given DependencyList
  * instance.
  *
  * Two DependencyList instances are considered identical if their
  * dependency list keys (the instance IDs) matches according to
  * the PHP == array operator specification. Please note that this
  * method does not check if the two instance are really the same
  * instance. It also doesn't check the instantiated dependencies
  * on the two objects. As long as the instance IDs on the list is
  * the same, the two object is considered identical.
  *
  * @return bool TRUE if considered identical, FALSE otherwise
  *
  */
 public function isIdentical(DependencyList $dependencyList)
 {
     $listA = array_keys($dependencyList->getList());
     $listB = array_keys($this->list);
     return $listA == $listB;
 }
 /**
  * Wire the dependencies provided to the object, returning the
  * instantiated object.
  * 
  * @param DependencyList $dependencyList The dependency list of
  *        this class, with all dependencies fulfilled.
  * @return mixed The object that this injector is supposed to
  *         instantiate.
  *
  */
 public function inject(DependencyList $dependencyList)
 {
     return $dependencyList->getInstantiatedDependency($this->referredReference);
 }
 /**
  * Generates an argument array ready to be used in running the
  * callback from the given DependencyList instance and the
  * {@see $args} class property.
  * 
  * Loops through {@see $args} class property and changes each
  * instance of Reference into an instantiated dependency instance
  * retrieved from the provided DependencyList.
  *
  * @param DependencyList $dependencyList
  * @return array Arguments array ready to be used for running the
  *         callback.
  *
  */
 protected function generateCallbackArguments(DependencyList $dependencyList)
 {
     $callbackArgs = array();
     foreach ($this->args as $value) {
         if ($value instanceof Reference) {
             $callbackArgs[] = $dependencyList->getInstantiatedDependency($value);
             continue;
         }
         $callbackArgs[] = $value;
     }
     return $callbackArgs;
 }
 /**
  * Add dependencies from the DependencyList instance given to the
  * stack.
  *
  * @see get()
  * @see addToStack()
  * @param DependencyList $dependencyList The dependency list to
  *        be added to the stack.
  * @param index $dependencyOf The index of the stack item that owns
  *        the given dependency list.
  *
  */
 protected function addDependenciesToStack(DependencyList $dependencyList, $dependencyOf)
 {
     foreach ($dependencyList->getList() as $reference) {
         $this->addToStack($reference, $dependencyOf);
     }
 }