Changeset View
Changeset View
Standalone View
Standalone View
src/Tasks/Task.php
<?php | <?php | ||||
namespace Nasqueron\SAAS\PhpBB\Tasks; | namespace Nasqueron\SAAS\PhpBB\Tasks; | ||||
use BadMethodCallException; | |||||
use TypeError; | |||||
abstract class Task { | abstract class Task { | ||||
/// | |||||
/// Usage methods | |||||
/// | |||||
abstract public static function getUsage () : string; | |||||
/// | |||||
/// Runner methods | |||||
/// | |||||
abstract public function run () : void; | abstract public function run () : void; | ||||
/** | |||||
* @param string[] $args | |||||
* @suppress PhanParamTooMany | |||||
*/ | |||||
public static function runWithArgs (array $args) : void { | |||||
try { | |||||
$task = new static(...$args); | |||||
} catch (TypeError $exception) { | |||||
throw new BadMethodCallException; | |||||
} | |||||
$task->run(); | |||||
} | |||||
} | } |
Nasqueron DevCentral · If it had been much bigger the moon would have had a core of ice. · Powered by Phabricator