Last active
August 29, 2015 14:01
-
-
Save mageekguy/c002ec07dfc6cd176fe2 to your computer and use it in GitHub Desktop.
A grummfy factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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