@@ -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 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public static function isCLI() : bool { |
|
| 60 | + public static function isCLI () : bool { |
|
| 61 | 61 | return PHP_SAPI === 'cli'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Populate options and check for required ones |
| 66 | 66 | */ |
| 67 | - public function __construct() { |
|
| 67 | + public function __construct () { |
|
| 68 | 68 | $opts = getopt( self::SHORT_OPTS, self::LONG_OPTS ); |
| 69 | 69 | $this->checkRequiredOpts( $opts ); |
| 70 | 70 | $this->checkConflictingOpts( $opts ); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * @param array $opts |
| 77 | 77 | */ |
| 78 | - private function checkRequiredOpts( array $opts ) : void { |
|
| 78 | + private function checkRequiredOpts ( array $opts ) : void { |
|
| 79 | 79 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
| 80 | 80 | if ( $missingOpts ) { |
| 81 | 81 | exit( "Required options missing: " . implode( ', ', $missingOpts ) ); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * @param array $opts |
| 93 | 93 | */ |
| 94 | - private function checkConflictingOpts( array $opts ) : void { |
|
| 94 | + private function checkConflictingOpts ( array $opts ) : void { |
|
| 95 | 95 | $hasPw = array_key_exists( 'password', $opts ); |
| 96 | 96 | $hasPwFile = array_key_exists( 'use-password-file', $opts ); |
| 97 | 97 | if ( $hasPw && $hasPwFile ) { |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | /** |
| 109 | 109 | * @param array &$opts |
| 110 | 110 | */ |
| 111 | - private function canonicalize( array &$opts ) : void { |
|
| 111 | + private function canonicalize ( array &$opts ) : void { |
|
| 112 | 112 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
| 113 | 113 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
| 114 | - $opts['password'] = $pw; |
|
| 115 | - unset( $opts['use-password-file'] ); |
|
| 114 | + $opts[ 'password' ] = $pw; |
|
| 115 | + unset( $opts[ 'use-password-file' ] ); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * These are the options required by Config. |
| 121 | 121 | * @return array |
| 122 | 122 | */ |
| 123 | - public function getMainOpts() : array { |
|
| 123 | + public function getMainOpts () : array { |
|
| 124 | 124 | return array_intersect_key( |
| 125 | 125 | $this->opts, |
| 126 | 126 | array_fill_keys( Config::REQUIRED_OPTS, true ) |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | * @param mixed|null $default |
| 133 | 133 | * @return mixed |
| 134 | 134 | */ |
| 135 | - public function getOpt( string $opt, $default = null ) { |
|
| 136 | - return $this->opts[$opt] ?? $default; |
|
| 135 | + public function getOpt ( string $opt, $default = null ) { |
|
| 136 | + return $this->opts[ $opt ] ?? $default; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ] |
| 141 | 141 | */ |
| 142 | - public function getTaskOpt() : array { |
|
| 142 | + public function getTaskOpt () : array { |
|
| 143 | 143 | return array_intersect_key( |
| 144 | 144 | $this->opts, |
| 145 | 145 | [ 'task' => true, 'subtask' => true ] |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | /** |
| 150 | 150 | * @return string|null |
| 151 | 151 | */ |
| 152 | - public function getURL() : ?string { |
|
| 152 | + public function getURL () : ?string { |
|
| 153 | 153 | return $this->getOpt( 'force-url' ); |
| 154 | 154 | } |
| 155 | 155 | } |