Skip to content

Instantly share code, notes, and snippets.

@feketegy
Created July 14, 2013 16:45
Show Gist options
  • Save feketegy/5994894 to your computer and use it in GitHub Desktop.
Save feketegy/5994894 to your computer and use it in GitHub Desktop.
// --== GOOD ==--
class SomeClass
{
protected $_db = null;
public function __construct(Database $db)
{
$this->_db = $db;
}
}
$dic = DIC::create('database');
$a = new SomeClass($dic['database']);
// --== BAD ==--
class SomeClass
{
protected $_db = null;
public function __construct(DIC $dic)
{
$this->_db = $dic['database'];
}
}
$dic = DIC::create('database');
$a = new SomeClass($dic);
// --== WORST ==--
class SomeClass
{
protected $_db = null;
public function __construct()
{
$dic = DIC::create('database');
$this->_db = $dic['database'];
}
}
$a = new SomeClass();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment