Skip to content

Instantly share code, notes, and snippets.

@mkusher
Created June 28, 2014 11:54
Show Gist options
  • Save mkusher/0a437b8adeaa2e513c07 to your computer and use it in GitHub Desktop.
Save mkusher/0a437b8adeaa2e513c07 to your computer and use it in GitHub Desktop.
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