Created
June 28, 2014 11:54
-
-
Save mkusher/0a437b8adeaa2e513c07 to your computer and use it in GitHub Desktop.
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
class TasksWorkerFactory { | |
public function getWorker(Task $task){ | |
$task_type = get_class($task); | |
if(!array_key_exists($task_type, self::$map)) | |
throw new \Exception; | |
/** @var AbstractWorker $worker */ | |
$worker = new self::$map[$task_type]; | |
$worker->setTask($task); | |
return $worker; | |
} | |
protected static $map = [ | |
'Move' => '', | |
'Mining' => '', | |
'BuildingConstructing' => '', | |
'RoadConstructing' => '', | |
'Manufactoring' => '' | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment