<?php /** * Attention: The code IS the site. Try and figure me out. * Not a nerd like me? Skip to the last 5 lines. */ namespace Norg; abstract class Person { public $name; public $age; public $gender; public $job; private $significant_other; private $pet; public function setSignificantOther(Person $person) { $this->significant_other = $person; $person->setSignificantOther($this); // Love works in both directions (and is unending...) } public function setPetName(string $petname) { $this->pet = $petname; } public function setAge(int $age) { $this->age = $age; } } class PersonFactory { public static function create($name, $gender, $age, $job) { if($gender === "Man") { $person = new Man; } else { $person = new Woman; } $person->name = $name; $person->age = $age; $person->job = $job; return $person; } } class Man extends Person { public function __construct() { $this->gender = "Man"; } } class Woman extends Person { public function __construct() { $this->gender = "Woman"; } public function addChild($name, $gender) { return PersonFactory::create($name, $gender, 0, "Have fun"); } } $Doeke = PersonFactory::create('Doeke Norg', 'Man', 32, 'Back-end developer at iWink'); $Renate = PersonFactory::create('Renate Norg - van Dis', 'Woman', 32, 'Nurse at Martini Ziekenhuis'); $Doeke->setPetName('Wi-Fi'); // This is our cat $Doeke->setSignificantOther($Renate); // Enter endless-love-loop // The other loves of my life $Finn = $Renate->addChild('Finn','Man'); $Finn->setAge(4); $Owen = $Renate->addChild('Owen', 'Man'); $Owen->setAge(1); var_dump($Doeke);