public function bindConfigItem($name, $item, $source) { static $PATTERN = '/\\{\\s*?(.*?)\\s*?\\}/'; $key = Key::ofConstant(Named::name($name)); if (is_array($item)) { $elements = $this->bindConfigCollection($item, "{$name}.", $source); $binding = new ConfigCollectionBinding($name, $source, $elements); } else { if (preg_match_all($PATTERN, $item, $matches)) { $dependencies = []; foreach (preg_split($PATTERN, $item) as $constant) { if ($constant) { $dependencies[] = new ConstantValueBinding($key, $constant); } $dependency = array_shift($matches[1]); if ($dependency) { $dependencies[] = defined($dependency) ? new ConstantNameBinding($key, $dependency) : new LateBinding(Key::ofConstant(Named::name($dependency))); } } $binding = new ConfigItemBinding($name, $source, $dependencies); } else { $binding = new ConstantValueBinding($key, $item); } } $this->bindings->put($binding); return $binding; }
public function __construct($name, $source) { parent::__construct(Key::ofConstant(Named::name($name))); $this->name = $name; $this->source = $source; }