Example #1
0
 /**
  * @param Config $config
  * @param array $args
  * @return callable|null|object
  */
 protected function provide(Config $config, array $args = [])
 {
     $name = $this->solve($config->name());
     $parent = $this->configured($name);
     !$args && ($args = $config->args());
     if ($parent && !$parent instanceof Config) {
         return $this->hydrate($config, $this->create($this->solve($parent), $args));
     }
     if (!$parent || $name == $parent->name()) {
         return $this->hydrate($config, $this->make($name, $args));
     }
     return $this->provide($this->merge(clone $parent, $config), $args);
 }