| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare( strict_types=1 ); |
||
| 8 | class Bot { |
||
| 9 | /** @var Logger */ |
||
| 10 | private $logger; |
||
| 11 | |||
| 12 | const VERSION = 1.0; |
||
| 13 | |||
| 14 | public function __construct() { |
||
| 16 | } |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Internal call to TaskManager |
||
| 20 | * |
||
| 21 | * @param string $mode |
||
| 22 | * @param string|null $name |
||
| 23 | */ |
||
| 24 | private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) { |
||
| 25 | $activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name"; |
||
| 26 | $this->logger->info( "Starting $activity" ); |
||
| 27 | $manager = new TaskManager; |
||
| 28 | $res = $manager->run( $mode, $name ); |
||
| 29 | $line = '---------------------------------------------------'; |
||
| 30 | if ( $res->isOK() ) { |
||
| 31 | $this->logger->info( "Execution of $activity completed successfully.\n$line\n\n" ); |
||
| 32 | } else { |
||
| 33 | $this->logger->error( "Execution of $activity failed.\n$res\n$line\n\n" ); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Entry point for the whole process |
||
| 39 | */ |
||
| 40 | public function runAll() { |
||
| 41 | $this->run(); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Run a single task |
||
| 46 | * |
||
| 47 | * @param string $task |
||
| 48 | */ |
||
| 49 | public function runTask( string $task ) { |
||
| 50 | $this->run( TaskManager::MODE_TASK, $task ); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Run a single subtask, e.g. for debugging purposes |
||
| 55 | * |
||
| 56 | * @param string $subtask |
||
| 57 | */ |
||
| 58 | public function runSubtask( string $subtask ) { |
||
| 60 | } |
||
| 61 | } |
||
| 62 |