public function bind($id, $concrete, $singleton = false)
    {

        $concrete = $concrete ?: $id;

        if (!$concrete instanceof Closure) {
            
            // If the factory (resolver) is NOT a closure we assume,
            // that it is a classname and wrap it into a closure so it' s
            // easier when resolving.

            $concrete = function (Container $container) use ($id, $concrete) {

                $method = ($id == $concrete) ? 'build' : 'resolve';

                return $container->$method($concrete, array());
            };
        }


        $this->binds[$id] = compact('concrete', 'singleton');
    }
public function bind($id, $concrete, $singleton = false)
    {

        $concrete = $concrete ?: $id;

        if (!$concrete instanceof Closure) {
            
            // If the factory (resolver) is NOT a closure we assume,
            // that it is a classname and wrap it into a closure so it' s
            // easier when resolving.

            $concrete = function (Container $container) use ($id, $concrete) {

                $method = ($id == $concrete) ? 'build' : 'resolve';

                return $container->$method($concrete, array());
            };
        }


        $this->binds[$id] = compact('concrete', 'singleton');
    }
public function bind ( $ id , $ concrete , $ singleton = false ) { $ concrete = $ concrete ? : $ id ; if ( ! $ concrete instanceof Closure ) { // If the factory (resolver) is NOT a closure we assume, // that it is a classname and wrap it into a closure so it' s // easier when resolving. $ concrete = function ( Container $ container ) use ( $ id , $ concrete ) { $ method = ( $ id == $ concrete ) ? 'build' : 'resolve' ; return $ container -> $ method ( $ concrete , array ( ) ) ; } ; } $ this -> binds [ $ id ] = compact ( 'concrete' , 'singleton' ) ; }
Register a binding
@param  string               $id        The id (needed for resolving)
@param  Closure|string|null  $concrete  The factory
@param  boolean              $singleton Whether the binding should be a singelton
Register a binding