php - Where is the boundary of dependency injection -


an injection passing of dependency dependent object (a client) use it. (wiki)

i understand dependency injection:

private $exampleclass; private $name;  public function __construct ($name, exampleclass $exampleclass) {     $this->name = $name;     $this->exampleclass = $exampleclass; } 

but still di or not?

private $exampleclass; private $name;  public function __construct ($name, exampleclass $exampleclass = null) {     $this->name = $name;     $this->exampleclass = $exampleclass ?: new exampleclass($name); } 

thanks

in dependency injection when a needs b the application creates a , gives b. in contrast, in example, the class creates exampleclass. thus, it's not dependency injection.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -