Passed
Push — master ( d44ff3...b7eff8 )
by Daimona
01:47
created
includes/CLI.php 1 patch
Spacing   +15 added lines, -15 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
 			exit( '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
 			exit( '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
 			exit( "Can only use one of '$first' and '$second'" );
132 132
 		}
@@ -135,16 +135,16 @@  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
 
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 	 * @param mixed|null $default
154 154
 	 * @return mixed
155 155
 	 */
156
-	public function getOpt( string $opt, $default = null ) {
157
-		return $this->opts[$opt] ?? $default;
156
+	public function getOpt ( string $opt, $default = null ) {
157
+		return $this->opts[ $opt ] ?? $default;
158 158
 	}
159 159
 
160 160
 	/**
161 161
 	 * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ]
162 162
 	 */
163
-	public function getTaskOpt() : array {
163
+	public function getTaskOpt () : array {
164 164
 		return array_intersect_key(
165 165
 			$this->opts,
166 166
 			[ 'task' => true, 'subtask' => true ]
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	/**
171 171
 	 * @return string|null
172 172
 	 */
173
-	public function getURL() : ?string {
173
+	public function getURL () : ?string {
174 174
 		return $this->getOpt( 'force-url' );
175 175
 	}
176 176
 }
Please login to merge, or discard this patch.