Skip to content

Instantly share code, notes, and snippets.

@mageekguy
Last active August 29, 2015 14:01
Show Gist options
  • Save mageekguy/c002ec07dfc6cd176fe2 to your computer and use it in GitHub Desktop.
Save mageekguy/c002ec07dfc6cd176fe2 to your computer and use it in GitHub Desktop.
A grummfy factory
<?php
namespace grummfy;
interface worker
{
function execute();
}
interface job
{
function run($data);
}
interface launcher
{
function launch(job $job);
}
class firstWorker implements worker
{
private $data1 = '';
private $data2 = '';
public function __construct($data1, $data2)
{
$this->data1 = $data1;
$this->data2 = $data2;
}
function execute()
{
echo $this->data1 . PHP_EOL;
echo $this->data2 . PHP_EOL;
return $this;
}
}
class firstJob implements job
{
private $data = null;
function __construct($data)
{
$this->data = $data;
}
function run($data)
{
(new firstWorker($this->data, $data))->execute();
return $this;
}
}
class firstLauncher implements launcher
{
private $data = null;
function __construct($data)
{
$this->data = $data;
}
function launch(job $job)
{
$job->run($this->data);
return $this;
}
}
(new firstLauncher('launcher data'))->launch(new firstJob('job data'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment