Skip to content

Instantly share code, notes, and snippets.

@sasin91 sasin91/Person.php Secret
Created Jun 13, 2016

Embed
What would you like to do?
Bored.
<?php
/**
* Person
* @requires: PHP 7.1+
* @TODO: Description
* @TODO: Add further Contracts Err, Interfaces.
* @TODO: Implement definition of Lust and morph with Emotion where applicable
* @TODO: Implement relationships
*/
class Person extends Entity implements FamilyMember,
Reproducable,
EmotionallyEnabled,
ShouldQue,
Sociable,
HumanMind,
HumanBehavior
{
use SociallyAcceptableBehavior,
Consciousness;
public $facade, $gender, $type;
protected $attributes, $persona, $character;
private $details;
public function __construct($state)
{
$this->configureWith($state);
}
protected function configureWith($state)
{
// @TODO: Implement configuration of personal state
}
public function __wakeup()
{
$state = unserialize(DB::getLastSavedState());
$me = new static($state);
// @TODO: Refactor into MorningRoutine
$me->checkSchedule();
$me->consumeBreakfast();
$me->checkAppointments();
$me->updateSchedule();
$schedule = $me->getSchedule();
if(!$schedule->has('gymTime'))
{
$schema = $schedule->get('workoutSchema');
if($workout = $schema->for((new Time())->today())->has('workout'))
{
$schedule->put('gymTime', $workout);
}
}
if($schedule->has('appointments'))
{
foreach ($schedule->get('appointments') as $appointment) {
queue()->for($me)->push($appointment);
}
}
// @TODO: Implement events and more.
// @consider: Using a switch.
if($me->hasJob() && $me->isExpectedAtWorkToday())
{
// Pun intended.
$me->goTo(Work::class);
} else {
$me->checkPersonalProjects();
if($me->wantsToImproveProject())
{
$me->improveProject();
} else {
$me->playGames();
}
}
}
public function __sleep(Time $period)
{
$me = New \ReflectionClass($this);
// TODO: Implement methods below...
// TODO: Refactor into SleepRoutine
$me->introspect('*');
$me->validateSchedule('today');
$me->considerTommorow();
$me->checkAlarm();
$expectedTimeAsleep = $me->evaluteActualSleepPeriod($period);
$state = serialize($me);
DB::store($state);
try {
sleep($expectedTimeAsleep);
} catch (Dream $dream) {
if($dream->isLucid())
{
$dream->inject($me)->observe();
}
if($dream->isNightmare())
{
$dream->cancel();
$dream->newOrWakeup();
}
} catch(Interuption $annoyance) {
$annoyance->handle();
$me->resumeSleep();
}
}
protected function routine(Routine $routine, Time $period)
{
while ($period->isNotExpired()) {
$routine->for($this)->execute();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.