Last active
September 11, 2017 23:56
-
-
Save nouka/9702de750a5c48a325201fd6a0387f2d to your computer and use it in GitHub Desktop.
DI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Client | |
{ | |
private $service; | |
public function __construct() | |
{ | |
$this->service = new Service(); | |
} | |
public function get() | |
{ | |
$conn = $this->service->connect(); | |
} | |
} | |
class Service | |
{ | |
public function connect() | |
{ | |
} | |
} | |
class Client | |
{ | |
private $service; | |
public function __construct(Service $service) | |
{ | |
$this->service = $service; | |
} | |
} | |
class Client | |
{ | |
private $service; | |
public function __construct() | |
{ | |
} | |
public function setService(Service $service) | |
{ | |
$this->service = $service; | |
} | |
} | |
class Client | |
{ | |
private $service; | |
public function __construct(ServiceInterface $service) | |
{ | |
$this->service = $service; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment