@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | * Entry point for the whole process |
| 17 | 17 | */ |
| 18 | 18 | public function run() { |
| 19 | - $this->logger->info( 'Starting full process.' ); |
|
| 19 | + $this->logger->info('Starting full process.'); |
|
| 20 | 20 | $manager = new TaskManager; |
| 21 | - $res = $manager->run( TaskManager::MODE_COMPLETE ); |
|
| 21 | + $res = $manager->run(TaskManager::MODE_COMPLETE); |
|
| 22 | 22 | $line = '---------------------------------------------------'; |
| 23 | - if ( $res->isOK() ) { |
|
| 24 | - $this->logger->info( "Execution completed successfully.\n$line\n\n" ); |
|
| 23 | + if ($res->isOK()) { |
|
| 24 | + $this->logger->info("Execution completed successfully.\n$line\n\n"); |
|
| 25 | 25 | } else { |
| 26 | - $this->logger->error( "Execution failed.\n$res\n$line\n\n" ); |
|
| 26 | + $this->logger->error("Execution failed.\n$res\n$line\n\n"); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
@@ -32,15 +32,15 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param string $task |
| 34 | 34 | */ |
| 35 | - public function runSingle( string $task ) { |
|
| 36 | - $this->logger->info( "Starting single task $task." ); |
|
| 35 | + public function runSingle(string $task) { |
|
| 36 | + $this->logger->info("Starting single task $task."); |
|
| 37 | 37 | $manager = new TaskManager; |
| 38 | - $res = $manager->run( TaskManager::MODE_SINGLE, $task ); |
|
| 38 | + $res = $manager->run(TaskManager::MODE_SINGLE, $task); |
|
| 39 | 39 | $line = '---------------------------------------------------'; |
| 40 | - if ( $res->isOK() ) { |
|
| 41 | - $this->logger->info( "Execution of $task completed successfully.\n$line\n\n" ); |
|
| 40 | + if ($res->isOK()) { |
|
| 41 | + $this->logger->info("Execution of $task completed successfully.\n$line\n\n"); |
|
| 42 | 42 | } else { |
| 43 | - $this->logger->error( "Execution of $task failed.\n$res\n$line\n\n" ); |
|
| 43 | + $this->logger->error("Execution of $task failed.\n$res\n$line\n\n"); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | require __DIR__ . '/vendor/autoload.php'; |
| 4 | 4 | |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | use BotRiconferme\Bot; |
| 7 | 7 | use BotRiconferme\Request\RequestBase; |
| 8 | 8 | |
| 9 | -if ( PHP_SAPI !== 'cli' ) { |
|
| 10 | - exit( 'CLI only!' ); |
|
| 9 | +if (PHP_SAPI !== 'cli') { |
|
| 10 | + exit('CLI only!'); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** MAIN PARAMS */ |
@@ -26,14 +26,14 @@ discard block |
||
| 26 | 26 | 'config-title:' |
| 27 | 27 | ]; |
| 28 | 28 | |
| 29 | -$vals = getopt( '', $params ); |
|
| 30 | -if ( count( $vals ) !== count( $params ) ) { |
|
| 31 | - exit( 'Not enough params!' ); |
|
| 29 | +$vals = getopt('', $params); |
|
| 30 | +if (count($vals) !== count($params)) { |
|
| 31 | + exit('Not enough params!'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /* URL (for debugging purpose) */ |
| 35 | -$url = getopt( '', [ 'force-url:' ] ); |
|
| 36 | -if ( isset( $url['force-url'] ) ) { |
|
| 35 | +$url = getopt('', ['force-url:']); |
|
| 36 | +if (isset($url['force-url'])) { |
|
| 37 | 37 | RequestBase::$url = $url['force-url']; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -47,38 +47,38 @@ discard block |
||
| 47 | 47 | * --use-password-file |
| 48 | 48 | * which will look for a $PWFILE file in the current directory containing only the plain password |
| 49 | 49 | */ |
| 50 | -$pwParams = getopt( '', [ |
|
| 50 | +$pwParams = getopt('', [ |
|
| 51 | 51 | 'password:', |
| 52 | 52 | 'use-password-file' |
| 53 | -] ); |
|
| 53 | +]); |
|
| 54 | 54 | |
| 55 | -if ( isset( $pwParams[ 'password' ] ) ) { |
|
| 56 | - $pw = $pwParams[ 'password' ]; |
|
| 57 | -} elseif ( isset( $pwParams[ 'use-password-file' ] ) ) { |
|
| 58 | - if ( file_exists( $PWFILE ) ) { |
|
| 59 | - $pw = trim( file_get_contents( $PWFILE ) ); |
|
| 55 | +if (isset($pwParams['password'])) { |
|
| 56 | + $pw = $pwParams['password']; |
|
| 57 | +} elseif (isset($pwParams['use-password-file'])) { |
|
| 58 | + if (file_exists($PWFILE)) { |
|
| 59 | + $pw = trim(file_get_contents($PWFILE)); |
|
| 60 | 60 | } else { |
| 61 | - exit( 'Please create a password.txt file to use with use-password-file' ); |
|
| 61 | + exit('Please create a password.txt file to use with use-password-file'); |
|
| 62 | 62 | } |
| 63 | 63 | } else { |
| 64 | - exit( 'Please provide a password or use a password file' ); |
|
| 64 | + exit('Please provide a password or use a password file'); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -$vals[ 'password' ] = $pw; |
|
| 67 | +$vals['password'] = $pw; |
|
| 68 | 68 | |
| 69 | 69 | /* START */ |
| 70 | 70 | |
| 71 | -Config::init( $vals ); |
|
| 71 | +Config::init($vals); |
|
| 72 | 72 | |
| 73 | 73 | $bot = new Bot(); |
| 74 | 74 | |
| 75 | 75 | /* |
| 76 | 76 | * E.g. --task=update-list |
| 77 | 77 | */ |
| 78 | -$taskOpts = getopt( '', [ 'task:' ] ); |
|
| 78 | +$taskOpts = getopt('', ['task:']); |
|
| 79 | 79 | |
| 80 | -if ( $taskOpts ) { |
|
| 81 | - $bot->runSingle( $taskOpts[ 'task' ] ); |
|
| 80 | +if ($taskOpts) { |
|
| 81 | + $bot->runSingle($taskOpts['task']); |
|
| 82 | 82 | } else { |
| 83 | 83 | $bot->run(); |
| 84 | 84 | } |