36 lines
953 B
PHP
36 lines
953 B
PHP
<?php
|
|
|
|
namespace NoccyLabs\Hotfix\Runner;
|
|
|
|
use NoccyLabs\Hotfix\System\Facts;
|
|
use NoccyLabs\Hotfix\Hotfix\Hotfix;
|
|
use NoccyLabs\Hotfix\Exception\UnsupportedRunnerException;
|
|
use NoccyLabs\Hotfix\Exception\NotCompatibleException;
|
|
|
|
class RunnerFactory
|
|
{
|
|
public static function createRunner(Hotfix $hotfix)
|
|
{
|
|
$facts = Facts::getSystemFacts();
|
|
$meta = $hotfix->getHeader();
|
|
|
|
switch ($meta->getLanguage()) {
|
|
case 'php':
|
|
$runner = new PhpRunner();
|
|
break;
|
|
case 'bash':
|
|
$runner = new BashRunner();
|
|
break;
|
|
case 'python':
|
|
$runner = new PythonRunner();
|
|
break;
|
|
default:
|
|
throw new UnsupportedRunnerException("This version of hotfix doesn't support the runner ".$meta->getLanguage());
|
|
}
|
|
|
|
$runner->prepare($hotfix, $facts);
|
|
|
|
return $runner;
|
|
}
|
|
|
|
} |