Created
May 15, 2014 23:15
-
-
Save auroraeosrose/ac3fac53ef804ad642b9 to your computer and use it in GitHub Desktop.
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
class Entity | |
{ | |
protected $model; | |
protected function initModel() { | |
$this->model = []; | |
} | |
public function __construct() { | |
$this->initModel(); | |
} | |
} | |
class Cat extends Entity | |
{ | |
protected $unique = | |
[ | |
'cry'=>'meow', | |
'food'=>'meat' | |
]; | |
protected function initModel() { | |
parent::initModel(); | |
$this->model = array_merge($this->unique, $this->model); | |
} | |
} | |
class Tiger extends Cat | |
{ | |
protected $new_stuff = | |
[ | |
'cry'=>'roar', | |
'ability'=>'pounce' | |
]; | |
protected function initModel() { | |
parent::initModel(); | |
$this->model = array_merge($this->new_stuff, $this->model); | |
} | |
} | |
class Sabertooth extends Tiger | |
{ | |
} | |
class Chimera extends Sabertooth | |
{ | |
protected $shiny_stuff = | |
[ | |
'ability'=>'fly', | |
'food'=>'heroes' | |
]; | |
protected function initModel() { | |
parent::initModel(); | |
$this->model = array_merge($this->shiny_stuff, $this->model); | |
} | |
} | |
$cat = new Cat; | |
$tiger = new Tiger; | |
$chimera = new Chimera; | |
var_dump($cat); | |
var_dump($tiger); | |
var_dump($chimera); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment