Skip to content

Instantly share code, notes, and snippets.

@auroraeosrose
Created May 15, 2014 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auroraeosrose/ac3fac53ef804ad642b9 to your computer and use it in GitHub Desktop.
Save auroraeosrose/ac3fac53ef804ad642b9 to your computer and use it in GitHub Desktop.
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