Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function get(string $name)
 {
     if (!isset($this->services[$name])) {
         throw ServiceNotFoundException::fromName($name);
     }
     return $this->services[$name]($this);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function get(string $name)
 {
     if (!$this->container->has($name)) {
         throw ServiceNotFoundException::fromName($name);
     }
     try {
         return $this->container->get($name);
     } catch (Exception $exception) {
         throw new ServiceContainerException($exception->getMessage(), $name, $exception);
     }
 }
 public function test_that_from_name_returns_expected_instance()
 {
     $exception = ServiceNotFoundException::fromName('event_dispatcher');
     $this->assertSame('Undefined service: event_dispatcher', $exception->getMessage());
 }