<?php
/**
 * Cedric Kastner
 * 
 * No geek/developer? Click here to see the readable output of this class ;-)
 *
 * @package Mankind
 * @author Evolution <evolution@earth.solarsystem.milkyway.universe.meta>
 * @version 1.0
 */
class Cedric_Kastner extends Human_Being
{
    static private $instance;
    
    private $arr_birth = array('name'    => 'Cedric Kastner',
                               'place'   => 'Essen, Germany',
                               'date'    => '1983-05-04',
                               'gender'  => 'male');
    
    private $arr_childhood = array('state' => 'North Rhine-Westphalia', 
                                   'area'  => 'Ruhr area');
    
    private $arr_teenager = array('passion' => array('computers', 'internet', 'new media'), 
                                  'firstpc' => array('Intel Celeron 300 MHz', '128 MB', '10 GB', '56K modem', 'AOL'));
    
    private $arr_education = array('schooleducation' => 'secondary school',
                                   'apprenticeship'  => 'digital media designer',
                                   'concentration'   => 'consulting &amp; strategy');
    
    private $arr_carreer = array(array('via one! multimedia GmbH', 'trainee in web development'), 
                                 array('BitDefender', 'technical consultant'),
                                 array('MEHRKANAL GmbH', 'web developer'),
                                 array('GPDevelopment', 'web developer'));
    
    private $arr_social = array('facebook'  => 'http://facebook.com/nurtext',
                                'twitter'   => 'http://twitter.com/nurtext',
                                'flickr'    => 'http://www.flickr.com/photos/nur-text',
                                'delicious' => 'http://delicious.com/nurtext',
                                'xing'      => 'https://www.xing.com/profile/Cedric_Kastner');
    
    private function __construct() {}
    private function __clone() {}
    
    public function __toString()
    {
        $str_content = sprintf('<h1>%1$s</h1><h2>Birth &amp; Childhood</h2><p>%2$s</p><p>%3$s</p>
                               <h2>Teenager &amp; Education</h2><p>%4$s</p><p>%5$s</p>
                               <h2>Carreer</h2><p>%6$s</p>
                               <h2>Social Networks</h2><p>%7$s</p>', 
                               $this->arr_birth['name'], 
                               $this->birth(), 
                               $this->childhood(),
                               $this->teenager(),
                               $this->education(),
                               $this->carreer(),
                               $this->social());
        
        $str_output  = sprintf('<!DOCTYPE html><html><head><meta charset="UTF-8"><title>%1$s</title>
                               <link rel="stylesheet" href="style.css"></head><article>%2$s</article>
                               <body></body></html>', 
                               $this->arr_birth['name'], 
                               $str_content);
        
        return $str_output;
        
    }
    
    static function getInstance()
    {
        if (self::$instance === NULL)
        {
            self::$instance = new self;
            
        }

        return self::$instance;
        
    }
    
    private function birth()
    {
        $obj_birth = new DateTime($this->arr_birth['date']);
        
        return sprintf('%1$s was born on %3$s in <em>%2$s.</em>', 
                       $this->arr_birth['name'], 
                       $this->arr_birth['place'], 
                       $obj_birth->format('M, jS Y'));
        
    }
    
    private function childhood()
    {
        return sprintf('He grew up in <em>%1$s</em> in one of Germany\'s largest urban areas called <em>%2$s</em>.', 
                       $this->arr_childhood['state'], 
                       $this->arr_childhood['area']);
    }
    
    private function teenager()
    {
        return sprintf('Soon he discovered his passion for <em>%1$s, %2$s and %3$s</em>, and after his first part time job he 
                       bought himself the first PC: %4$s with %5$s of RAM and %6$s disk space. The &quot;first contact&quot; 
                       with the internet was made using an %7$s when dialing into %8$s.', 
                       $this->arr_teenager['passion'][0],
                       $this->arr_teenager['passion'][1],
                       $this->arr_teenager['passion'][2],
                       $this->arr_teenager['firstpc'][0],
                       $this->arr_teenager['firstpc'][1],
                       $this->arr_teenager['firstpc'][2],
                       $this->arr_teenager['firstpc'][3],
                       $this->arr_teenager['firstpc'][4]);
    }
    
    private function education()
    {
        return sprintf('After leaving the %1$s he started his apprenticeship as <em>%2$s</em> with a concentration in %3$s.',
                       $this->arr_education['schooleducation'],
                       $this->arr_education['apprenticeship'],
                       $this->arr_education['concentration']);
        
    }
    
    private function carreer()
    {
        return sprintf('Once he\'d finished his apprenticeship, he started working as %1$s for <em>%2$s</em>. After moving to 
                       <em>Lake Constance</em> he started to work as %3$s for <em>%4$s</em>. Three years later he decided to go 
                       back to his roots and worked as %5$s for <em>%6$s</em>. Since 2008 he\'s still working as %7$s for a 
                       small company called <em>%8$s</em>.',
                       $this->arr_carreer[0][1],
                       $this->arr_carreer[0][0],
                       $this->arr_carreer[1][1],
                       $this->arr_carreer[1][0],
                       $this->arr_carreer[2][1],
                       $this->arr_carreer[2][0],
                       $this->arr_carreer[3][1],
                       $this->arr_carreer[3][0]);
    }
    
    private function social()
    {
        return sprintf('You can find him on <a href="%1$s">Facebook</a>, <a href="%2$s">Twitter</a>, <a href="%3$s">Flickr</a>,
                       <a href="%4$s">Delicious</a> and <a href="%5$s">Xing</a>.',
                       $this->arr_social['facebook'],
                       $this->arr_social['twitter'],
                       $this->arr_social['flickr'],
                       $this->arr_social['delicious'],
                       $this->arr_social['xing']);
        
    }
    
}

// Instantiate singleton class
$cedric = Cedric_Kastner::getInstance();

// Print the class
printf($cedric);