Passed
Push — master ( 42646c...5be6a5 )
by Daimona
07:46
created
src/CLI.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 	/**
67 67
 	 * @return bool
68 68
 	 */
69
-	public static function isCLI(): bool {
69
+	public static function isCLI (): bool {
70 70
 		return PHP_SAPI === 'cli';
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * Populate options and check for required ones
75 75
 	 */
76
-	public function __construct() {
76
+	public function __construct () {
77 77
 		/** @var string[] $opts */
78 78
 		$opts = getopt( self::SHORT_OPTS, self::LONG_OPTS );
79 79
 		$this->checkRequiredOpts( $opts );
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	/**
86 86
 	 * @param string[] $opts
87 87
 	 */
88
-	private function checkRequiredOpts( array $opts ): void {
88
+	private function checkRequiredOpts ( array $opts ): void {
89 89
 		$missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) );
90 90
 		if ( $missingOpts ) {
91 91
 			$this->fatal( 'Required options missing: ' . implode( ', ', $missingOpts ) );
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	/**
108 108
 	 * @param string[] $opts
109 109
 	 */
110
-	private function checkConflictingOpts( array $opts ): void {
110
+	private function checkConflictingOpts ( array $opts ): void {
111 111
 		$this->checkNotBothSet( $opts, 'password', 'use-password-file' );
112 112
 		if ( array_key_exists( 'use-password-file', $opts ) && !file_exists( self::PASSWORD_FILE ) ) {
113 113
 			$this->fatal( 'Please create the password file (' . self::PASSWORD_FILE . ')' );
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $first
129 129
 	 * @param string $second
130 130
 	 */
131
-	private function checkNotBothSet( array $opts, string $first, string $second ): void {
131
+	private function checkNotBothSet ( array $opts, string $first, string $second ): void {
132 132
 		if ( array_key_exists( $first, $opts ) && array_key_exists( $second, $opts ) ) {
133 133
 			$this->fatal( "Can only use one of '$first' and '$second'" );
134 134
 		}
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 	/**
138 138
 	 * @param string[] &$opts
139 139
 	 */
140
-	private function canonicalize( array &$opts ): void {
140
+	private function canonicalize ( array &$opts ): void {
141 141
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
142 142
 			$pw = trim( file_get_contents( self::PASSWORD_FILE ) );
143
-			$opts['password'] = $pw;
144
-			unset( $opts['use-password-file'] );
143
+			$opts[ 'password' ] = $pw;
144
+			unset( $opts[ 'use-password-file' ] );
145 145
 		}
146 146
 		if ( array_key_exists( 'use-private-password-file', $opts ) ) {
147 147
 			$pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) );
148
-			$opts['private-password'] = $pw;
149
-			unset( $opts['use-private-password-file'] );
148
+			$opts[ 'private-password' ] = $pw;
149
+			unset( $opts[ 'use-private-password-file' ] );
150 150
 		}
151 151
 	}
152 152
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @param string $msg
155 155
 	 * @return never
156 156
 	 */
157
-	private function fatal( string $msg ): void {
157
+	private function fatal ( string $msg ): void {
158 158
 		exit( $msg . "\n" );
159 159
 	}
160 160
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 	 * @param string $opt
164 164
 	 * @return string
165 165
 	 */
166
-	public function getSetOpt( string $opt ): string {
167
-		return $this->opts[$opt];
166
+	public function getSetOpt ( string $opt ): string {
167
+		return $this->opts[ $opt ];
168 168
 	}
169 169
 
170 170
 	/**
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	 * @param string|null $default
173 173
 	 * @return string|null
174 174
 	 */
175
-	public function getOpt( string $opt, string $default = null ): ?string {
176
-		return $this->opts[$opt] ?? $default;
175
+	public function getOpt ( string $opt, string $default = null ): ?string {
176
+		return $this->opts[ $opt ] ?? $default;
177 177
 	}
178 178
 
179 179
 	/**
180 180
 	 * @return string[] Either [ 'tasks' => name1,... ] or [ 'subtasks' => name1,... ]
181 181
 	 */
182
-	public function getTaskOpt(): array {
182
+	public function getTaskOpt (): array {
183 183
 		return array_intersect_key(
184 184
 			$this->opts,
185 185
 			[ 'tasks' => true, 'subtasks' => true ]
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	/**
190 190
 	 * @return string|null
191 191
 	 */
192
-	public function getURL(): ?string {
192
+	public function getURL (): ?string {
193 193
 		return $this->getOpt( 'force-url' );
194 194
 	}
195 195
 }
Please login to merge, or discard this patch.