public function bind($name, $value, $shared = false, $protected = false)
    {
        if (is_string($value)) {
            $value = function (Container $container) use ($value) {
                // We must check the keys exists or not, if exists, just get it instead new one.
                if ($container->exists($value)) {
                    return $container->get($value);
                }

                return $container->newInstance($value);
            };
        }

        return $this->set($name, $value, $shared, $protected);
    }
public function bind($name, $value, $shared = false, $protected = false)
    {
        if (is_string($value)) {
            $value = function (Container $container) use ($value) {
                // We must check the keys exists or not, if exists, just get it instead new one.
                if ($container->exists($value)) {
                    return $container->get($value);
                }

                return $container->newInstance($value);
            };
        }

        return $this->set($name, $value, $shared, $protected);
    }
public function bind ( $ name , $ value , $ shared = false , $ protected = false ) { if ( is_string ( $ value ) ) { $ value = function ( Container $ container ) use ( $ value ) { // We must check the keys exists or not, if exists, just get it instead new one. if ( $ container -> exists ( $ value ) ) { return $ container -> get ( $ value ) ; } return $ container -> newInstance ( $ value ) ; } ; } return $ this -> set ( $ name , $ value , $ shared , $ protected ) ; }
Bind a class or key to another instance, container will return instance if it has been set
or created, otherwise it will create new one.

@param   string $name
@param   mixed  $value
@param   bool   $shared
@param   bool   $protected

@return  static

@since   3.0
Bind a class or key to another instance container will return instance if it has been set or created otherwise it will create new one .