Skip to content

Instantly share code, notes, and snippets.

@nouka
Last active September 11, 2017 23:56
Show Gist options
  • Save nouka/9702de750a5c48a325201fd6a0387f2d to your computer and use it in GitHub Desktop.
Save nouka/9702de750a5c48a325201fd6a0387f2d to your computer and use it in GitHub Desktop.
DI
<?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