original_string: public function get($key)
      {
          $key = strtolower($key);
  
          if (!isset($this->services[$key])) {
              throw new \InvalidArgumentException('Service not found: ' . $key);
          }
  
          // Have we been here before?
          if (isset($this->loadedService[$key])) {
              return $this->loadedService[$key];
          }
  
          if (!$this->services[$key] instanceof Service) {
              $this->loadedService[$key] = $this->services[$key];
  
              return $this->loadedService[$key];
          }
  
          // It's a Service instance, lets do some extra stuff.
          if (!$this->services[$key]->hasClassName()) {
              throw new \Exception('Unable to find class name from definition: ' . $key);
          }
  
          $className = $this->services[$key]->getClassName();
          $instance  = new $className();
  
          if ($this->services[$key]->hasFactoryMethod()) {
              call_user_func($instance, $this->services[$key]->getFactoryMethod());
          }
  
          $this->loadedService[$key] = $instance;
  
          return $this->loadedService[$key];
      }
code: public function get($key)
      {
          $key = strtolower($key);
  
          if (!isset($this->services[$key])) {
              throw new \InvalidArgumentException('Service not found: ' . $key);
          }
  
          // Have we been here before?
          if (isset($this->loadedService[$key])) {
              return $this->loadedService[$key];
          }
  
          if (!$this->services[$key] instanceof Service) {
              $this->loadedService[$key] = $this->services[$key];
  
              return $this->loadedService[$key];
          }
  
          // It's a Service instance, lets do some extra stuff.
          if (!$this->services[$key]->hasClassName()) {
              throw new \Exception('Unable to find class name from definition: ' . $key);
          }
  
          $className = $this->services[$key]->getClassName();
          $instance  = new $className();
  
          if ($this->services[$key]->hasFactoryMethod()) {
              call_user_func($instance, $this->services[$key]->getFactoryMethod());
          }
  
          $this->loadedService[$key] = $instance;
  
          return $this->loadedService[$key];
      }
code_tokens: public function get ( $ key ) { $ key = strtolower ( $ key ) ; if ( ! isset ( $ this -> services [ $ key ] ) ) { throw new \ InvalidArgumentException ( 'Service not found: ' . $ key ) ; } // Have we been here before? if ( isset ( $ this -> loadedService [ $ key ] ) ) { return $ this -> loadedService [ $ key ] ; } if ( ! $ this -> services [ $ key ] instanceof Service ) { $ this -> loadedService [ $ key ] = $ this -> services [ $ key ] ; return $ this -> loadedService [ $ key ] ; } // It's a Service instance, lets do some extra stuff. if ( ! $ this -> services [ $ key ] -> hasClassName ( ) ) { throw new \ Exception ( 'Unable to find class name from definition: ' . $ key ) ; } $ className = $ this -> services [ $ key ] -> getClassName ( ) ; $ instance = new $ className ( ) ; if ( $ this -> services [ $ key ] -> hasFactoryMethod ( ) ) { call_user_func ( $ instance , $ this -> services [ $ key ] -> getFactoryMethod ( ) ) ; } $ this -> loadedService [ $ key ] = $ instance ; return $ this -> loadedService [ $ key ] ; }
docstring: Get a registered service by its name.
  
  @param string $key
  
  @throws \Exception|\InvalidArgumentException
  
  @return mixed
docstring_tokens: Get a registered service by its name .