Beispiel #1
0
 public function testGetReturnsSetValue()
 {
     $registry = new Registry();
     $value = 'myValue';
     $registry->set('key', $value);
     $this->assertEquals($value, $registry->get('key'));
 }
Beispiel #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));
     }
 }