@@ -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 | $missing = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
79 | 79 | if ( $missing ) { |
80 | 80 | exit( "Required options missing: " . implode( ', ', $missing ) ); |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @param array &$opts |
100 | 100 | */ |
101 | - private function canonicalize( array &$opts ) : void { |
|
101 | + private function canonicalize ( array &$opts ) : void { |
|
102 | 102 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
103 | 103 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
104 | - $opts['password'] = $pw; |
|
105 | - unset( $opts['use-password-file'] ); |
|
104 | + $opts[ 'password' ] = $pw; |
|
105 | + unset( $opts[ 'use-password-file' ] ); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * These are the options required by Config. |
111 | 111 | * @return array |
112 | 112 | */ |
113 | - public function getMainOpts() : array { |
|
113 | + public function getMainOpts () : array { |
|
114 | 114 | return array_intersect_key( |
115 | 115 | $this->opts, |
116 | 116 | array_fill_keys( Config::REQUIRED_OPTS, true ) |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | * @param mixed|null $default |
123 | 123 | * @return mixed |
124 | 124 | */ |
125 | - public function getOpt( string $opt, $default = null ) { |
|
126 | - return $this->opts[$opt] ?? $default; |
|
125 | + public function getOpt ( string $opt, $default = null ) { |
|
126 | + return $this->opts[ $opt ] ?? $default; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ] |
131 | 131 | */ |
132 | - public function getTaskOpt() : array { |
|
132 | + public function getTaskOpt () : array { |
|
133 | 133 | return array_intersect_key( |
134 | 134 | $this->opts, |
135 | 135 | [ 'task' => true, 'subtask' => true ] |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | /** |
140 | 140 | * @return string|null |
141 | 141 | */ |
142 | - public function getURL() : ?string { |
|
142 | + public function getURL () : ?string { |
|
143 | 143 | return $this->getOpt( 'force-url' ); |
144 | 144 | } |
145 | 145 | } |