class Zoo {
protected $monkey;
public function __construct()
{
$this->monkey = new Monkey();
}
}
class Zoo {
protected $monkey;
public function __construct(Monkey $monkey)
{
$this->monkey = $monkey;
}
public function foo() {
return $this->monkey->foo;
}
}
class Monkey {
public $foo;
}
$monkey = new Monkey();
$monkey->foo = "bar";
$zoo = new Zoo($monkey);
echo $zoo->foo();