Skip to content

Commit 0b19cd3

Browse files
committed
Fixed coding standards with CS Fixer
1 parent 6140a5e commit 0b19cd3

2 files changed

Lines changed: 20 additions & 24 deletions

File tree

src/CLI/CLI.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use Exception;
66
use Utopia\Validator;
77

8-
class CLI {
9-
8+
class CLI
9+
{
1010
/**
1111
* Command
1212
*
@@ -153,17 +153,16 @@ public function parse(array $args): array
153153
{
154154
\array_shift($args); // Remove script path from args
155155

156-
if(isset($args[0])) {
156+
if (isset($args[0])) {
157157
$this->command = \array_shift($args);
158-
}
159-
else {
158+
} else {
160159
throw new Exception('Missing command');
161160
}
162161

163162
$output = [];
164163

165164
foreach ($args as &$arg) {
166-
if(\substr($arg, 0, 2) === '--') {
165+
if (\substr($arg, 0, 2) === '--') {
167166
$arg = \substr($arg, 2);
168167
}
169168
}
@@ -183,14 +182,14 @@ public function run(): self
183182
$command = isset($this->tasks[$this->command]) ? $this->tasks[$this->command] : null;
184183

185184
try {
186-
if($command) {
187-
foreach($this->init as $init) {
185+
if ($command) {
186+
foreach ($this->init as $init) {
188187
\call_user_func_array($init, []);
189188
}
190189

191190
$params = [];
192191

193-
foreach($command->getParams() as $key => $param) {
192+
foreach ($command->getParams() as $key => $param) {
194193
// Get value from route or request object
195194
$value = (isset($this->args[$key])) ? $this->args[$key] : $param['default'];
196195

@@ -202,15 +201,13 @@ public function run(): self
202201
// Call the callback with the matched positions as params
203202
\call_user_func_array($command->getAction(), $params);
204203

205-
foreach($this->shutdown as $shutdown) {
204+
foreach ($this->shutdown as $shutdown) {
206205
\call_user_func_array($shutdown, []);
207206
}
208-
}
209-
else {
207+
} else {
210208
throw new Exception('No command found');
211209
}
212-
}
213-
catch (Exception $e) {
210+
} catch (Exception $e) {
214211
\call_user_func_array($this->error, array($e));
215212
}
216213

@@ -233,7 +230,7 @@ protected function validate(string $key, array $param, $value): void
233230
// checking whether the class exists
234231
$validator = $param['validator'];
235232

236-
if(\is_callable($validator)) {
233+
if (\is_callable($validator)) {
237234
$validator = $validator();
238235
}
239236

@@ -245,9 +242,10 @@ protected function validate(string $key, array $param, $value): void
245242
if (!$validator->isValid($value)) {
246243
throw new Exception('Invalid ' .$key . ': ' . $validator->getDescription(), 400);
247244
}
248-
}
249-
else if (!$param['optional']) {
250-
throw new Exception('Param "' . $key . '" is not optional.', 400);
245+
} else {
246+
if (!$param['optional']) {
247+
throw new Exception('Param "' . $key . '" is not optional.', 400);
248+
}
251249
}
252250
}
253251
}

src/CLI/Console.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static public function warning(string $message)
9292
*/
9393
static public function confirm(string $question)
9494
{
95-
if(!self::isInteractive()) {
95+
if (!self::isInteractive()) {
9696
return '';
9797
}
9898

@@ -152,20 +152,18 @@ static public function execute(string $cmd, string $stdin, string &$stdout, stri
152152
\fclose($pipes[0]);
153153
}
154154

155-
while(\is_resource($process))
156-
{
155+
while (\is_resource($process)) {
157156
$stdout .= \stream_get_contents($pipes[1]);
158157
$stderr .= \stream_get_contents($pipes[2]);
159158

160-
if($timeout > 0 && \time() - $start > $timeout)
161-
{
159+
if ($timeout > 0 && \time() - $start > $timeout) {
162160
\proc_terminate($process, 9);
163161
return 1;
164162
}
165163

166164
$status = \proc_get_status($process);
167165

168-
if(!$status['running']) {
166+
if (!$status['running']) {
169167
\fclose($pipes[1]);
170168
\fclose($pipes[2]);
171169
\proc_close($process);

0 commit comments

Comments
 (0)