예제 #1
0
파일: Object.php 프로젝트: hopehp/di
 /**
  * Instantiate object definition
  *
  * @param string $name
  * @param string $value
  * @throws \InvalidArgumentException
  */
 public function __construct($name, $value)
 {
     if (class_exists($value) === false) {
         throw new \InvalidArgumentException('Object definition value must be a name of existing class');
     }
     parent::__construct($name, $value);
 }
예제 #2
0
파일: SimpleBuilder.php 프로젝트: hopehp/di
 /**
  * Build Closure definition
  *
  * @param \Hope\Di\IContainer         $container
  * @param \Hope\Di\Definition\Closure $definition
  *
  * @protected
  *
  * @return mixed
  */
 protected function buildFactory(IContainer $container, Closure $definition)
 {
     $callable = $definition->getValue();
     $arguments = $definition->getArguments();
     return $callable(...$this->resolveValues($container, ...$arguments));
 }