March 31, 2012 | Action | submitted by Berumen
Inception
class Dream
{
const DREAM_LEVEL = 1;
public function goToSleep() {
try {
$this->goDeeper( self::DREAM_LEVEL );
} catch (MyException $e) {
throw new Exception("You're actually in the middle of the workshop right now, sleeping");
}
}
protected function goDeeper($dreamLevel) {
try{
$dreamLevel+=1;
$this->goDeeper($dreamLevel);
} catch (MyException $e) {
throw new Exception('Your world is not real!');
}
}
}
$alfredo = new Dream;
try{
$alfredo->goToSleep();
} catch (Inception $kick) {
echo 'Think about it '.$kick->getName().', how did you get here?';
}
?>