@@ -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->checkRequired( $opts ); |
| 70 | 70 | $this->canonicalize( $opts ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | /** |
| 75 | 75 | * @param array $opts |
| 76 | 76 | */ |
| 77 | - private function checkRequired( array $opts ) : void { |
|
| 77 | + private function checkRequired ( array $opts ) : void { |
|
| 78 | 78 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
| 79 | 79 | $hasPw = array_key_exists( 'password', $opts ); |
| 80 | 80 | $hasPwFile = array_key_exists( 'use-password-file', $opts ); |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | /** |
| 96 | 96 | * @param array &$opts |
| 97 | 97 | */ |
| 98 | - private function canonicalize( array &$opts ) : void { |
|
| 98 | + private function canonicalize ( array &$opts ) : void { |
|
| 99 | 99 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
| 100 | 100 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
| 101 | - $opts['password'] = $pw; |
|
| 102 | - unset( $opts['use-password-file'] ); |
|
| 101 | + $opts[ 'password' ] = $pw; |
|
| 102 | + unset( $opts[ 'use-password-file' ] ); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * These are the options required by Config. |
| 108 | 108 | * @return array |
| 109 | 109 | */ |
| 110 | - public function getMainOpts() : array { |
|
| 110 | + public function getMainOpts () : array { |
|
| 111 | 111 | return array_intersect_key( |
| 112 | 112 | $this->opts, |
| 113 | 113 | array_fill_keys( Config::REQUIRED_OPTS, true ) |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | * @param mixed|null $default |
| 120 | 120 | * @return mixed |
| 121 | 121 | */ |
| 122 | - public function getOpt( string $opt, $default = null ) { |
|
| 123 | - return $this->opts[$opt] ?? $default; |
|
| 122 | + public function getOpt ( string $opt, $default = null ) { |
|
| 123 | + return $this->opts[ $opt ] ?? $default; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ] |
| 128 | 128 | */ |
| 129 | - public function getTaskOpt() : array { |
|
| 129 | + public function getTaskOpt () : array { |
|
| 130 | 130 | return array_intersect_key( |
| 131 | 131 | $this->opts, |
| 132 | 132 | [ 'task' => true, 'subtask' => true ] |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | /** |
| 137 | 137 | * @return string|null |
| 138 | 138 | */ |
| 139 | - public function getURL() : ?string { |
|
| 139 | + public function getURL () : ?string { |
|
| 140 | 140 | return $this->getOpt( 'force-url' ); |
| 141 | 141 | } |
| 142 | 142 | } |