Ejemplo n.º 1
0
 public function testDottedResolutionOfMissingKeyReturnsCorrectValue()
 {
     $data = array('key' => array());
     $resolver = new ArrayResolver($data);
     $this->assertEquals('default', $resolver->resolve('key.sub-key', 'default'));
     $this->assertEquals('other-default', $resolver->resolve('key.other-key', 'other-default'));
 }
Ejemplo n.º 2
0
 /**
  * Retrieve a class configured in the container
  * @param  string $serviceName
  * @return object
  */
 public function get($serviceName)
 {
     if ($this->registry->has($serviceName)) {
         return $this->registry->get($serviceName);
     }
     $serviceConfig = $this->classes->resolve($serviceName, null);
     if ($serviceConfig == null) {
         throw new \DICIT\UnknownDefinitionException($serviceName);
     }
     try {
         return $this->loadService($serviceName, $serviceConfig->extract());
     } catch (\DICIT\UnknownDefinitionException $ex) {
         throw new \RuntimeException(sprintf("Dependency '%s' not found while trying to build '%s'.", $ex->getServiceName(), $serviceName));
     }
 }