Skip to content

Commit 81c46c2

Browse files
committed
Code-style patch.
1 parent 4c6c380 commit 81c46c2

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
4747
### v3.3.1
4848

4949
[2024.07.02; Maikuolan]: Merged zh and zh-TW L10N, and dropped region designations (e.g., CN, TW) in favour of script designations (e.g., Hans, Hant).
50+
51+
[2024.09.02; Maikuolan]: Code-style patch.

src/CLI.php

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: CLI handler (last modified: 2023.12.01).
11+
* This file: CLI handler (last modified: 2024.09.02).
1212
*/
1313

1414
namespace phpMussel\CLI;
@@ -119,31 +119,35 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
119119
if (substr($Command, 0, 10) === 'hash_file:') {
120120
$this->LastAlgo = substr($Command, 10);
121121
echo "\n" . $this->hashFile($Clean);
122+
continue;
122123
}
123124

124125
/** Generate a CoEx signature using a file. */
125-
elseif ($Command === 'coex_file') {
126+
if ($Command === 'coex_file') {
126127
echo "\n" . $this->coexFile($Clean);
128+
continue;
127129
}
128130

129131
/** Fetch PE metadata. */
130-
elseif ($Command === 'pe_meta') {
132+
if ($Command === 'pe_meta') {
131133
echo "\n" . $this->peMeta($Clean);
134+
continue;
132135
}
133136

134137
/** Generate a hash signature using a string. */
135-
elseif (substr($Command, 0, 5) === 'hash:') {
138+
if (substr($Command, 0, 5) === 'hash:') {
136139
$this->LastAlgo = substr($Command, 5);
137140
if (in_array($this->LastAlgo, hash_algos())) {
138141
$TargetData = substr($Clean, strlen($Command) + 1);
139142
echo "\n" . hash($this->LastAlgo, $TargetData) . ':' . strlen($TargetData) . ':' . $this->Loader->L10N->getString('cli_signature_placeholder') . "\n";
140143
} else {
141144
echo "\n" . $this->Loader->L10N->getString('cli_algo_not_supported') . "\n";
142145
}
146+
continue;
143147
}
144148

145149
/** Generate a URL scanner signature from a URL. */
146-
elseif ($Command === 'url_sig') {
150+
if ($Command === 'url_sig') {
147151
echo "\n";
148152
$Clean = $this->Scanner->normalise(substr($Clean, strlen($Command) + 1));
149153
$URL = ['AvoidMe' => '', 'ForThis' => ''];
@@ -184,57 +188,64 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
184188
}
185189
}
186190
unset($URL);
191+
continue;
187192
}
188193

189194
/** Generate a CoEx signature using a string. */
190-
elseif (preg_match('~^(?:(?:[Cc]|ϲ|с)(?:[Oo]|ο|о)(?:[Ee]|е)(?:[Xx]|х))$~', $CommandNatural)) {
195+
if (preg_match('~^(?:(?:[Cc]|ϲ|с)(?:[Oo]|ο|о)(?:[Ee]|е)(?:[Xx]|х))$~', $CommandNatural)) {
191196
$TargetData = substr($Clean, strlen($Command) + 1);
192197
echo sprintf(
193198
"\n\$sha256:%s;\$StringLength:%d;%s\n",
194199
hash('sha256', $TargetData),
195200
strlen($TargetData),
196201
$this->Loader->L10N->getString('cli_signature_placeholder')
197202
);
203+
continue;
198204
}
199205

200206
/** Convert a binary string to a hexadecimal. */
201-
elseif (preg_match('~^(?:[Hh][Ee][Xx]_[Ee][Nn][Cc][Oo][Dd][Ee]|[Xx]|х)$~', $CommandNatural)) {
207+
if (preg_match('~^(?:[Hh][Ee][Xx]_[Ee][Nn][Cc][Oo][Dd][Ee]|[Xx]|х)$~', $CommandNatural)) {
202208
$TargetData = substr($Clean, strlen($Command) + 1);
203209
echo "\n" . bin2hex($TargetData) . "\n";
210+
continue;
204211
}
205212

206213
/** Convert a hexadecimal to a binary string. */
207-
elseif ($Command === 'hex_decode') {
214+
if ($Command === 'hex_decode') {
208215
$TargetData = substr($Clean, strlen($Command) + 1);
209216
echo "\n" . ($this->Loader->hexSafe($TargetData) ?: $this->Loader->L10N->getString('response.Invalid data')) . "\n";
217+
continue;
210218
}
211219

212220
/** Convert a binary string to a base64 string. */
213-
elseif ($Command === 'base64_encode' || $Command === 'b') {
221+
if ($Command === 'base64_encode' || $Command === 'b') {
214222
$TargetData = substr($Clean, strlen($Command) + 1);
215223
echo "\n" . base64_encode($TargetData) . "\n";
224+
continue;
216225
}
217226

218227
/** Convert a base64 string to a binary string. */
219-
elseif ($Command === 'base64_decode') {
228+
if ($Command === 'base64_decode') {
220229
$TargetData = substr($Clean, strlen($Command) + 1);
221230
echo "\n" . (base64_decode($TargetData) ?: $this->Loader->L10N->getString('response.Invalid data')) . "\n";
231+
continue;
222232
}
223233

224234
/** Scan a file or directory. */
225-
elseif (preg_match('~^(?:[Ss][Cc][Aa][Nn]|[Ss]|ѕ)$~', $CommandNatural)) {
235+
if (preg_match('~^(?:[Ss][Cc][Aa][Nn]|[Ss]|ѕ)$~', $CommandNatural)) {
226236
$TargetData = substr($Clean, strlen($Command) + 1);
227-
echo "\n";
228-
echo $this->Scanner->scan($TargetData) . "\n";
237+
echo "\n" . $this->Scanner->scan($TargetData) . "\n";
238+
continue;
229239
}
230240

231241
/** Print the command list. */
232-
elseif (preg_match('~^(?:[Cc]|ϲ|с)$~', $CommandNatural)) {
242+
if (preg_match('~^(?:[Cc]|ϲ|с)$~', $CommandNatural)) {
233243
echo "\n" . $this->Loader->L10N->getString('cli_commands');
244+
continue;
234245
}
235246

236247
/** Print a list of supported algorithms. */
237-
elseif ($Command === 'algo') {
248+
if ($Command === 'algo') {
238249
echo "\n";
239250
$Algos = hash_algos();
240251
$Pos = 1;
@@ -252,12 +263,11 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
252263
}
253264
}
254265
echo "\n";
266+
continue;
255267
}
256268

257269
/** Bad command notice. */
258-
else {
259-
echo "\n" . $this->Loader->L10N->getString('bad_command') . "\n";
260-
}
270+
echo "\n" . $this->Loader->L10N->getString('bad_command') . "\n";
261271
}
262272
}
263273

0 commit comments

Comments
 (0)