Ouzo\Injection\InjectorConfig::bind PHP Method

bind() public method

public bind ( $className, $name = '' )
    public function bind($className, $name = '')
    {
        $className = Strings::prependIfMissing($className, '\\');
        $binder = new Binder($className, $name);
        $this->binders[$className . '_' . $name] = $binder;
        return $binder;
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function shouldModifyConfigAfterCreation()
 {
     //given
     $object = new ClassWithNoDep();
     $config = new InjectorConfig();
     $injector = new Injector($config);
     $config->bind('\\ClassWithNoDep')->toInstance($object);
     //ControllerTestCase exposes injectorConfig and allows users to add their bindings after injector is created
     //when
     $instance = $injector->getInstance('\\ClassWithNoDep');
     //then
     $this->assertSame($object, $instance);
 }
All Usage Examples Of Ouzo\Injection\InjectorConfig::bind