@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * Class Parameter |
55 | 55 | * @package Platine\Console\Input |
56 | 56 | */ |
57 | -abstract class Parameter |
|
58 | -{ |
|
57 | +abstract class Parameter { |
|
59 | 58 | |
60 | 59 | /** |
61 | 60 | * The name of the parameter |
@@ -183,8 +182,7 @@ discard block |
||
183 | 182 | * Return the parameter default value |
184 | 183 | * @return mixed |
185 | 184 | */ |
186 | - public function getDefault() |
|
187 | - { |
|
185 | + public function getDefault() { |
|
188 | 186 | if ($this->isVariadic()) { |
189 | 187 | return (array) $this->default; |
190 | 188 | } |
@@ -234,8 +232,7 @@ discard block |
||
234 | 232 | * @param mixed $raw |
235 | 233 | * @return mixed |
236 | 234 | */ |
237 | - public function filter($raw) |
|
238 | - { |
|
235 | + public function filter($raw) { |
|
239 | 236 | if ($this->filter !== null) { |
240 | 237 | $callback = $this->filter; |
241 | 238 |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * Class Argument |
53 | 53 | * @package Platine\Console\Input |
54 | 54 | */ |
55 | -class Argument extends Parameter |
|
56 | -{ |
|
55 | +class Argument extends Parameter { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
@@ -248,9 +248,9 @@ |
||
248 | 248 | |
249 | 249 | foreach ($choices as $choice => $desc) { |
250 | 250 | $this->writer->eol() |
251 | - ->cyan( |
|
252 | - str_pad(' [' . $choice . ']', $maxLength + 6) |
|
253 | - ); |
|
251 | + ->cyan( |
|
252 | + str_pad(' [' . $choice . ']', $maxLength + 6) |
|
253 | + ); |
|
254 | 254 | |
255 | 255 | $this->writer->dim($desc); |
256 | 256 | } |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * Class Interactor |
59 | 59 | * @package Platine\Console\IO |
60 | 60 | */ |
61 | -class Interactor |
|
62 | -{ |
|
61 | +class Interactor { |
|
63 | 62 | |
64 | 63 | /** |
65 | 64 | * Stream reader instance |
@@ -78,8 +77,7 @@ discard block |
||
78 | 77 | * @param string|null $input |
79 | 78 | * @param string|null $output |
80 | 79 | */ |
81 | - public function __construct(?string $input = null, ?string $output = null) |
|
82 | - { |
|
80 | + public function __construct(?string $input = null, ?string $output = null) { |
|
83 | 81 | $this->reader = new Reader($input); |
84 | 82 | $this->writer = new Writer($output); |
85 | 83 | } |
@@ -124,8 +122,7 @@ discard block |
||
124 | 122 | * |
125 | 123 | * @return mixed |
126 | 124 | */ |
127 | - public function choice(string $text, array $choices, $default = null, bool $case = false) |
|
128 | - { |
|
125 | + public function choice(string $text, array $choices, $default = null, bool $case = false) { |
|
129 | 126 | $this->writer->yellow($text); |
130 | 127 | |
131 | 128 | $this->listOptions($choices, $default, false); |
@@ -146,8 +143,7 @@ discard block |
||
146 | 143 | * |
147 | 144 | * @return mixed |
148 | 145 | */ |
149 | - public function choices(string $text, array $choices, $default = null, bool $case = false) |
|
150 | - { |
|
146 | + public function choices(string $text, array $choices, $default = null, bool $case = false) { |
|
151 | 147 | $this->writer->yellow($text); |
152 | 148 | |
153 | 149 | $this->listOptions($choices, $default, true); |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * Class Cursor |
53 | 53 | * @package Platine\Console\Output |
54 | 54 | */ |
55 | -class Cursor |
|
56 | -{ |
|
55 | +class Cursor { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * Returns signal to move cursor up "count" times. |
@@ -55,8 +55,7 @@ |
||
55 | 55 | * Class Table |
56 | 56 | * @package Platine\Console\Output |
57 | 57 | */ |
58 | -class Table |
|
59 | -{ |
|
58 | +class Table { |
|
60 | 59 | |
61 | 60 | /** |
62 | 61 | * Render table data |
@@ -607,8 +607,7 @@ discard block |
||
607 | 607 | * @method Writer darkgrayBgWhite(string $text, bool $eol = false) |
608 | 608 | * @method Writer darkgrayBgGray(string $text, bool $eol = false) |
609 | 609 | */ |
610 | -class Writer |
|
611 | -{ |
|
610 | +class Writer { |
|
612 | 611 | |
613 | 612 | /** |
614 | 613 | * The output stream |
@@ -645,8 +644,7 @@ discard block |
||
645 | 644 | * @param string|null $path the output write path |
646 | 645 | * @param Color|null $color the color instance |
647 | 646 | */ |
648 | - public function __construct(?string $path = null, ?Color $color = null) |
|
649 | - { |
|
647 | + public function __construct(?string $path = null, ?Color $color = null) { |
|
650 | 648 | $stream = null; |
651 | 649 | if ($path !== null) { |
652 | 650 | $stream = fopen($path, 'w'); |
@@ -773,8 +771,7 @@ discard block |
||
773 | 771 | * @param array<int, mixed> $args |
774 | 772 | * @return $this |
775 | 773 | */ |
776 | - public function __call(string $method, array $args = []) |
|
777 | - { |
|
774 | + public function __call(string $method, array $args = []) { |
|
778 | 775 | if (method_exists($this->cursor, $method)) { |
779 | 776 | return $this->cursor->{$method}(...$args); |
780 | 777 | } |
@@ -609,8 +609,7 @@ discard block |
||
609 | 609 | * @method string darkgrayBgWhite(string $text) |
610 | 610 | * @method string darkgrayBgGray(string $text) |
611 | 611 | */ |
612 | -class Color |
|
613 | -{ |
|
612 | +class Color { |
|
614 | 613 | |
615 | 614 | /** |
616 | 615 | * The color constants |
@@ -766,8 +765,7 @@ discard block |
||
766 | 765 | * @return mixed |
767 | 766 | * @throws Error |
768 | 767 | */ |
769 | - public function __call(string $method, array $args = []) |
|
770 | - { |
|
768 | + public function __call(string $method, array $args = []) { |
|
771 | 769 | $colors = [ |
772 | 770 | 'black' => self::BLACK, |
773 | 771 | 'red' => self::RED, |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class Reader |
53 | 53 | * @package Platine\Console\Input |
54 | 54 | */ |
55 | -class Reader |
|
56 | -{ |
|
55 | +class Reader { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * The input stream |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | * Create new instance |
66 | 65 | * @param string|null $path the input read path |
67 | 66 | */ |
68 | - public function __construct(?string $path = null) |
|
69 | - { |
|
67 | + public function __construct(?string $path = null) { |
|
70 | 68 | $stream = STDIN; |
71 | 69 | if ($path !== null) { |
72 | 70 | $stream = fopen($path, 'r'); |
@@ -81,8 +79,7 @@ discard block |
||
81 | 79 | * @param callable|null $callback The validator/sanitizer callback. |
82 | 80 | * @return mixed |
83 | 81 | */ |
84 | - public function read($default = null, ?callable $callback = null) |
|
85 | - { |
|
82 | + public function read($default = null, ?callable $callback = null) { |
|
86 | 83 | $input = ''; |
87 | 84 | $read = fgets($this->stream); |
88 | 85 | |
@@ -104,8 +101,7 @@ discard block |
||
104 | 101 | * @param callable|null $callback The validator/sanitizer callback. |
105 | 102 | * @return mixed |
106 | 103 | */ |
107 | - public function readAll(?callable $callback = null) |
|
108 | - { |
|
104 | + public function readAll(?callable $callback = null) { |
|
109 | 105 | $input = stream_get_contents($this->stream); |
110 | 106 | |
111 | 107 | return $callback !== null |
@@ -118,8 +114,7 @@ discard block |
||
118 | 114 | * @param callable|null $callback The validator/sanitizer callback. |
119 | 115 | * @return mixed |
120 | 116 | */ |
121 | - public function readPipe(?callable $callback = null) |
|
122 | - { |
|
117 | + public function readPipe(?callable $callback = null) { |
|
123 | 118 | $stdin = ''; |
124 | 119 | $read = [$this->stream]; |
125 | 120 | $write = []; |
@@ -145,8 +140,7 @@ discard block |
||
145 | 140 | * @param callable|null $callback The validator/sanitizer callback. |
146 | 141 | * @return mixed |
147 | 142 | */ |
148 | - public function readHidden($default = null, ?callable $callback = null) |
|
149 | - { |
|
143 | + public function readHidden($default = null, ?callable $callback = null) { |
|
150 | 144 | if (substr(strtoupper(PHP_OS), 0, 3) === 'WIN') { |
151 | 145 | return $this->readHiddenWindows($default, $callback); |
152 | 146 | } |
@@ -167,8 +161,7 @@ discard block |
||
167 | 161 | * @param callable|null $callback The validator/sanitizer callback. |
168 | 162 | * @return mixed |
169 | 163 | */ |
170 | - protected function readHiddenWindows($default = null, ?callable $callback = null) |
|
171 | - { |
|
164 | + protected function readHiddenWindows($default = null, ?callable $callback = null) { |
|
172 | 165 | $cmd = 'powershell -Command ' . implode('; ', array_filter([ |
173 | 166 | '$pword = Read-Host -AsSecureString', |
174 | 167 | '$pword = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword)', |
@@ -578,17 +578,17 @@ |
||
578 | 578 | protected function defaults(): self |
579 | 579 | { |
580 | 580 | $this->addOption('-h|--help', 'Show help') |
581 | - ->on([$this, 'showHelp']); |
|
581 | + ->on([$this, 'showHelp']); |
|
582 | 582 | |
583 | 583 | $this->addOption('-v|--version', 'Show version') |
584 | - ->on([$this, 'showVersion']); |
|
584 | + ->on([$this, 'showVersion']); |
|
585 | 585 | |
586 | 586 | $this->addOption('-V|--verbosity', 'Verbosity level', 0) |
587 | - ->on(function () { |
|
587 | + ->on(function () { |
|
588 | 588 | $this->set('verbosity', ++$this->verbosity); |
589 | 589 | |
590 | 590 | return false; |
591 | - }); |
|
591 | + }); |
|
592 | 592 | |
593 | 593 | $this->onExit(function (int $exitCode = 0) { |
594 | 594 | $this->terminate($exitCode); |
@@ -584,13 +584,13 @@ |
||
584 | 584 | ->on([$this, 'showVersion']); |
585 | 585 | |
586 | 586 | $this->addOption('-V|--verbosity', 'Verbosity level', 0) |
587 | - ->on(function () { |
|
587 | + ->on(function() { |
|
588 | 588 | $this->set('verbosity', ++$this->verbosity); |
589 | 589 | |
590 | 590 | return false; |
591 | 591 | }); |
592 | 592 | |
593 | - $this->onExit(function (int $exitCode = 0) { |
|
593 | + $this->onExit(function(int $exitCode = 0) { |
|
594 | 594 | $this->terminate($exitCode); |
595 | 595 | }); |
596 | 596 |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | * Class Command |
65 | 65 | * @package Platine\Console\Command |
66 | 66 | */ |
67 | -class Command extends Parser |
|
68 | -{ |
|
67 | +class Command extends Parser { |
|
69 | 68 | |
70 | 69 | /** |
71 | 70 | * The command version |
@@ -396,8 +395,7 @@ discard block |
||
396 | 395 | * Show this command help and abort |
397 | 396 | * @return mixed |
398 | 397 | */ |
399 | - public function showHelp() |
|
400 | - { |
|
398 | + public function showHelp() { |
|
401 | 399 | $io = $this->io(); |
402 | 400 | $helper = new OutputHelper($io->writer()); |
403 | 401 | |
@@ -443,8 +441,7 @@ discard block |
||
443 | 441 | * Show this command version and abort |
444 | 442 | * @return mixed |
445 | 443 | */ |
446 | - public function showVersion() |
|
447 | - { |
|
444 | + public function showVersion() { |
|
448 | 445 | $this->writer()->bold( |
449 | 446 | sprintf( |
450 | 447 | '%s, %s', |
@@ -461,8 +458,7 @@ discard block |
||
461 | 458 | * Execute the command |
462 | 459 | * @return mixed |
463 | 460 | */ |
464 | - public function execute() |
|
465 | - { |
|
461 | + public function execute() { |
|
466 | 462 | } |
467 | 463 | |
468 | 464 | /** |
@@ -481,16 +477,14 @@ discard block |
||
481 | 477 | * @param mixed $object |
482 | 478 | * @return mixed |
483 | 479 | */ |
484 | - public function tap($object = null) |
|
485 | - { |
|
480 | + public function tap($object = null) { |
|
486 | 481 | return $object ?? $this->app; |
487 | 482 | } |
488 | 483 | |
489 | 484 | /** |
490 | 485 | * {@inheritdoc} |
491 | 486 | */ |
492 | - public function emit(string $event, $value = null) |
|
493 | - { |
|
487 | + public function emit(string $event, $value = null) { |
|
494 | 488 | if (empty($this->events[$event])) { |
495 | 489 | return null; |
496 | 490 | } |
@@ -503,8 +497,7 @@ discard block |
||
503 | 497 | * @param string $longName |
504 | 498 | * @return mixed|null |
505 | 499 | */ |
506 | - public function getOptionValue(string $longName) |
|
507 | - { |
|
500 | + public function getOptionValue(string $longName) { |
|
508 | 501 | $values = $this->values(); |
509 | 502 | |
510 | 503 | return array_key_exists($longName, $values) |
@@ -517,8 +510,7 @@ discard block |
||
517 | 510 | * @param string $name |
518 | 511 | * @return mixed|null |
519 | 512 | */ |
520 | - public function getArgumentValue(string $name) |
|
521 | - { |
|
513 | + public function getArgumentValue(string $name) { |
|
522 | 514 | $values = $this->values(); |
523 | 515 | |
524 | 516 | return array_key_exists($name, $values) |
@@ -551,8 +543,7 @@ discard block |
||
551 | 543 | /** |
552 | 544 | * {@inheritdoc} |
553 | 545 | */ |
554 | - protected function handleUnknown(string $arg, $value = null) |
|
555 | - { |
|
546 | + protected function handleUnknown(string $arg, $value = null) { |
|
556 | 547 | if ($this->allowUnknown) { |
557 | 548 | return $this->set(Helper::toCamelCase($arg), $value); |
558 | 549 | } |