Passed
Push — master ( 795976...a1ef81 )
by Daimona
01:49
created
includes/CLI.php 1 patch
Spacing   +16 added lines, -16 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,23 +137,23 @@  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
 
153 153
 	/**
154 154
 	 * @param string $msg
155 155
 	 */
156
-	private function fatal( string $msg ) : void {
156
+	private function fatal ( string $msg ) : void {
157 157
 		exit( $msg . "\n" );
158 158
 	}
159 159
 
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
 	 * @param string $opt
162 162
 	 * @return string|null
163 163
 	 */
164
-	public function getOpt( string $opt ) : string {
165
-		return $this->opts[$opt];
164
+	public function getOpt ( string $opt ) : string {
165
+		return $this->opts[ $opt ];
166 166
 	}
167 167
 
168 168
 	/**
169 169
 	 * @return string[] Either [ 'tasks' => name1,... ] or [ 'subtasks' => name1,... ]
170 170
 	 */
171
-	public function getTaskOpt() : array {
171
+	public function getTaskOpt () : array {
172 172
 		return array_intersect_key(
173 173
 			$this->opts,
174 174
 			[ 'tasks' => true, 'subtasks' => true ]
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	/**
179 179
 	 * @return string|null
180 180
 	 */
181
-	public function getURL() : ?string {
181
+	public function getURL () : ?string {
182 182
 		return $this->getOpt( 'force-url' );
183 183
 	}
184 184
 }
Please login to merge, or discard this patch.