original_string: public function extend($name, callable $extender)
      {
          if (! isset($this->factories[$name])) {
              throw new Exception(
                  'Trying to extend unknown resource "' . $name . '"',
                  Exception::RESOURCE_NAME_UNKNOWN
              );
          }
          $factory = $this->factories[$name];
          $this->factories[$name] = $this->share(
              function ($container) use ($extender, $factory) {
                  return $extender($factory, $container);
              }
          );
      }
code: public function extend($name, callable $extender)
      {
          if (! isset($this->factories[$name])) {
              throw new Exception(
                  'Trying to extend unknown resource "' . $name . '"',
                  Exception::RESOURCE_NAME_UNKNOWN
              );
          }
          $factory = $this->factories[$name];
          $this->factories[$name] = $this->share(
              function ($container) use ($extender, $factory) {
                  return $extender($factory, $container);
              }
          );
      }
code_tokens: public function extend ( $ name , callable $ extender ) { if ( ! isset ( $ this -> factories [ $ name ] ) ) { throw new Exception ( 'Trying to extend unknown resource "' . $ name . '"' , Exception :: RESOURCE_NAME_UNKNOWN ) ; } $ factory = $ this -> factories [ $ name ] ; $ this -> factories [ $ name ] = $ this -> share ( function ( $ container ) use ( $ extender , $ factory ) { return $ extender ( $ factory , $ container ) ; } ) ; }
docstring: Extend a previously registered resource factory with an extender function.
  
  When called extender will receive two arguments:
  - the previously registered resource factory.
  - the container.
  It is up to extender whether to call the factory or not, and when, and how.
  Effectively extender is simply a resource factory with only difference
  that it receives the previous factory along with container instance.
  
  @param  string                      $name
  @param  mixed(self)(mixed(self))    $extender
docstring_tokens: Extend a previously registered resource factory with an extender function .