<?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($petname)
    {
        $this->pet = $petname;
    }
}

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 =	"Man";
    }
    
    public function addChild($name, $gender)
    {
        return PersonFactory::create($name,$gender,0,'Cry');
    }
}


$Doeke = PersonFactory::create("Doeke Norg", "Man", 28, "Webdeveloper at SQUID Media");
$Renate = PersonFactory::create("Renate Norg - van Dis", "Woman", 28, "Nurse at Martini Ziekenhuis");

$Doeke->setPetName("Wi-Fi"); // This is our cat
$Doeke->setSignificantOther($Renate); // Enter endless-love-loop

//The other love of my life
$Renate->addChild("Finn","Man");

var_dump($Doeke);