Passed
Push — master ( b7eff8...0d7491 )
by Daimona
01:54
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
 
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	/**
66 66
 	 * @return bool
67 67
 	 */
68
-	public static function isCLI() : bool {
68
+	public static function isCLI () : bool {
69 69
 		return PHP_SAPI === 'cli';
70 70
 	}
71 71
 
72 72
 	/**
73 73
 	 * Populate options and check for required ones
74 74
 	 */
75
-	public function __construct() {
75
+	public function __construct () {
76 76
 		$opts = getopt( self::SHORT_OPTS, self::LONG_OPTS );
77 77
 		$this->checkRequiredOpts( $opts );
78 78
 		$this->checkConflictingOpts( $opts );
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	/**
84 84
 	 * @param array $opts
85 85
 	 */
86
-	private function checkRequiredOpts( array $opts ) : void {
86
+	private function checkRequiredOpts ( array $opts ) : void {
87 87
 		$missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) );
88 88
 		if ( $missingOpts ) {
89 89
 			$this->fatal( 'Required options missing: ' . implode( ', ', $missingOpts ) );
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * @param array $opts
107 107
 	 */
108
-	private function checkConflictingOpts( array $opts ) : void {
108
+	private function checkConflictingOpts ( array $opts ) : void {
109 109
 		$this->checkNotBothSet( $opts, 'password', 'use-password-file' );
110 110
 		if ( array_key_exists( 'use-password-file', $opts ) && !file_exists( self::PASSWORD_FILE ) ) {
111 111
 			$this->fatal( 'Please create the password file (' . self::PASSWORD_FILE . ')' );
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param string $first
127 127
 	 * @param string $second
128 128
 	 */
129
-	private function checkNotBothSet( array $opts, string $first, string $second ) : void {
129
+	private function checkNotBothSet ( array $opts, string $first, string $second ) : void {
130 130
 		if ( array_key_exists( $first, $opts ) && array_key_exists( $second, $opts ) ) {
131 131
 			$this->fatal( "Can only use one of '$first' and '$second'" );
132 132
 		}
@@ -135,23 +135,23 @@  discard block
 block discarded – undo
135 135
 	/**
136 136
 	 * @param array &$opts
137 137
 	 */
138
-	private function canonicalize( array &$opts ) : void {
138
+	private function canonicalize ( array &$opts ) : void {
139 139
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
140 140
 			$pw = trim( file_get_contents( self::PASSWORD_FILE ) );
141
-			$opts['password'] = $pw;
142
-			unset( $opts['use-password-file'] );
141
+			$opts[ 'password' ] = $pw;
142
+			unset( $opts[ 'use-password-file' ] );
143 143
 		}
144 144
 		if ( array_key_exists( 'use-private-password-file', $opts ) ) {
145 145
 			$pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) );
146
-			$opts['private-password'] = $pw;
147
-			unset( $opts['use-private-password-file'] );
146
+			$opts[ 'private-password' ] = $pw;
147
+			unset( $opts[ 'use-private-password-file' ] );
148 148
 		}
149 149
 	}
150 150
 
151 151
 	/**
152 152
 	 * @param string $msg
153 153
 	 */
154
-	private function fatal( string $msg ) : void {
154
+	private function fatal ( string $msg ) : void {
155 155
 		exit( $msg . "\n" );
156 156
 	}
157 157
 
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 	 * @param mixed|null $default
161 161
 	 * @return mixed
162 162
 	 */
163
-	public function getOpt( string $opt, $default = null ) {
164
-		return $this->opts[$opt] ?? $default;
163
+	public function getOpt ( string $opt, $default = null ) {
164
+		return $this->opts[ $opt ] ?? $default;
165 165
 	}
166 166
 
167 167
 	/**
168 168
 	 * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ]
169 169
 	 */
170
-	public function getTaskOpt() : array {
170
+	public function getTaskOpt () : array {
171 171
 		return array_intersect_key(
172 172
 			$this->opts,
173 173
 			[ 'task' => true, 'subtask' => true ]
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	/**
178 178
 	 * @return string|null
179 179
 	 */
180
-	public function getURL() : ?string {
180
+	public function getURL () : ?string {
181 181
 		return $this->getOpt( 'force-url' );
182 182
 	}
183 183
 }
Please login to merge, or discard this patch.