Last active
August 29, 2015 14:18
-
-
Save blar/0c727dfa567afd09f502 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Foo1 { | |
private $bar; | |
public function getBar() { | |
if(!$this->bar) { | |
$this->bar = new Bar(); | |
} | |
return $this->bar; | |
} | |
} | |
class Foo2 { | |
private $bar; | |
public function __construct() { | |
$this->setBar(new Bar()); | |
} | |
public function setBar(Bar $bar) { | |
$this->bar = $bar; | |
return $this; | |
} | |
public function getBar() { | |
return $this->bar; | |
} | |
} | |
class Foo3 { | |
private $bar; | |
public function setBar(Bar $bar) { | |
$this->bar = $bar; | |
return $this; | |
} | |
public function getBar() { | |
if(!$this->bar) { | |
$this->setBar(new Bar()); | |
} | |
return $this->bar; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment