Skip to content

Commit 2753b80

Browse files
committed
Apply fixes from StyleCI
1 parent 97f5961 commit 2753b80

24 files changed

+750
-624
lines changed

Diff for: commands.php

+46-50
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,75 @@
11
<?php
22

33
/**
4-
*
54
* @author <[email protected]>
6-
* @package Conso PHP Console Creator
5+
*
76
* @version 1.0.0
7+
*
88
* @license MIT
9+
*
910
* @category CLI
11+
*
1012
* @copyright 2019 Lotfio Lakehal
1113
*/
12-
13-
$conso->command('--version', function($inp, $out, $app){
14-
15-
$out->writeLn("\n " . $app->getName() . " version " . $app->getVersion() . "\n", "yellow");
16-
14+
$conso->command('--version', function ($inp, $out, $app) {
15+
$out->writeLn("\n ".$app->getName().' version '.$app->getVersion()."\n", 'yellow');
1716
})->alias(['-v']);
1817

19-
$conso->command('--help', function($inp, $out, $app){
20-
21-
$out->writeLn("\nUsage: \n\n", 'yellow');
22-
$out->writeLn(" command:subcommand [options] [-flags]\n\n");
23-
24-
$out->writeLn("Special flags: \n\n", 'yellow');
25-
26-
$flags = $inp->reservedFlags();
27-
$out->writeLn(" " . $flags[0] . " ", 'green');
28-
$out->writeLn(" " . $flags[1] . " \n", 'green');
29-
$out->writeLn(" " . $flags[2] . " ", 'green');
30-
$out->writeLn(" " . $flags[3] . " \n", 'green');
31-
$out->writeLn(" " . $flags[4] . " ", 'green');
32-
$out->writeLn(" " . $flags[5] . " \n", 'green');
33-
$out->writeLn(" " . $flags[6] . " ", 'green');
34-
$out->writeLn(" " . $flags[7] . " \n", 'green');
35-
$out->writeLn(" " . $flags[8] . " ", 'green');
36-
$out->writeLn( $flags[9] . " \n", 'green');
37-
$out->writeLn(" " . $flags[10] . " ", 'green');
38-
$out->writeLn(" " . $flags[11] . " \n", 'green');
39-
40-
$out->writeLn("\nHelp: \n\n", 'yellow');
41-
$out->writeLn(" The help special flag displays help for a given command: \n\n");
42-
$out->writeLn(" To display application version, please use the -v or --version special flags.\n");
43-
$out->writeLn(" To display the list of available commands, please use the -c or --commands special flags.\n");
44-
$out->writeLn(" To silent warning, please use the -q or --quiet special flags.\n");
45-
$out->writeLn(" To disable ansi, please use the --no-ansi special flag.\n");
46-
18+
$conso->command('--help', function ($inp, $out, $app) {
19+
$out->writeLn("\nUsage: \n\n", 'yellow');
20+
$out->writeLn(" command:subcommand [options] [-flags]\n\n");
21+
22+
$out->writeLn("Special flags: \n\n", 'yellow');
23+
24+
$flags = $inp->reservedFlags();
25+
$out->writeLn(' '.$flags[0].' ', 'green');
26+
$out->writeLn(' '.$flags[1]." \n", 'green');
27+
$out->writeLn(' '.$flags[2].' ', 'green');
28+
$out->writeLn(' '.$flags[3]." \n", 'green');
29+
$out->writeLn(' '.$flags[4].' ', 'green');
30+
$out->writeLn(' '.$flags[5]." \n", 'green');
31+
$out->writeLn(' '.$flags[6].' ', 'green');
32+
$out->writeLn(' '.$flags[7]." \n", 'green');
33+
$out->writeLn(' '.$flags[8].' ', 'green');
34+
$out->writeLn($flags[9]." \n", 'green');
35+
$out->writeLn(' '.$flags[10].' ', 'green');
36+
$out->writeLn(' '.$flags[11]." \n", 'green');
37+
38+
$out->writeLn("\nHelp: \n\n", 'yellow');
39+
$out->writeLn(" The help special flag displays help for a given command: \n\n");
40+
$out->writeLn(" To display application version, please use the -v or --version special flags.\n");
41+
$out->writeLn(" To display the list of available commands, please use the -c or --commands special flags.\n");
42+
$out->writeLn(" To silent warning, please use the -q or --quiet special flags.\n");
43+
$out->writeLn(" To disable ansi, please use the --no-ansi special flag.\n");
4744
})->alias(['-h']);
4845

49-
$conso->command('--commands', function($inp, $out, $app){
46+
$conso->command('--commands', function ($inp, $out, $app) {
5047
// remove special commands
51-
$commands = array_filter($app->getCommands(), function($elem){
52-
if(strpos($elem['name'], '--') === FALSE) return $elem;
48+
$commands = array_filter($app->getCommands(), function ($elem) {
49+
if (strpos($elem['name'], '--') === false) {
50+
return $elem;
51+
}
5352
});
5453

55-
if(count($commands) > 0)
56-
{
54+
if (count($commands) > 0) {
5755
$out->writeLn("\nAvailable Commands: \n\n", 'yellow');
5856

59-
$max = max(array_map(function($elem){ return count($elem);}, $commands));
57+
$max = max(array_map(function ($elem) { return count($elem); }, $commands));
6058

61-
foreach($commands as $command)
62-
{
63-
$out->writeLn(" ". $command['name'] . str_repeat(' ', ($max - strlen($command['name'])) + 4 ), 'green');
64-
$out->writeLn($command['description'] . "\n");
59+
foreach ($commands as $command) {
60+
$out->writeLn(' '.$command['name'].str_repeat(' ', ($max - strlen($command['name'])) + 4), 'green');
61+
$out->writeLn($command['description']."\n");
6562
}
6663

6764
$out->writeLn("\n");
6865
}
69-
7066
})->alias(['-c']);
7167

72-
$conso->command('--no-ansi', function($inp, $out, $app){
68+
$conso->command('--no-ansi', function ($inp, $out, $app) {
7369
$out->disableAnsi(); // disable ansi
74-
$cm = explode(DIRECTORY_SEPARATOR, getcwd());
75-
$cmd = ' php ' . $cm[count($cm) - 1];
70+
$cm = explode(DIRECTORY_SEPARATOR, getcwd());
71+
$cmd = ' php '.$cm[count($cm) - 1];
7672
passthru($cmd);
7773
});
7874

79-
$conso->command('command', 'Conso\\Commands\\Command');
75+
$conso->command('command', 'Conso\\Commands\\Command');

Diff for: src/Conso/Command.php

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,74 @@
1-
<?php namespace Conso;
1+
<?php
2+
3+
namespace Conso;
24

35
/**
4-
*
56
* @author <[email protected]>
6-
* @package Conso PHP Console Creator
7+
*
78
* @version 1.0.0
9+
*
810
* @license MIT
11+
*
912
* @category CLI
13+
*
1014
* @copyright 2019 Lotfio Lakehal
1115
*/
1216

1317
use Conso\Contracts\InputInterface;
1418
use Conso\Contracts\OutputInterface;
1519

1620
/**
17-
* This class is base command class
21+
* This class is base command class.
1822
*/
1923
class Command
2024
{
2125
/**
22-
* base constructor
26+
* base constructor.
2327
*
24-
* @param InputInterface $input
28+
* @param InputInterface $input
2529
* @param OutputInterface $output
26-
* @param Conso $app
30+
* @param Conso $app
2731
*/
2832
public function __construct(InputInterface $input, OutputInterface $output, Conso $app)
2933
{
30-
if($input->flag(0) == '--no-ansi')
34+
if ($input->flag(0) == '--no-ansi') {
3135
$output->disableAnsi();
36+
}
3237

3338
//if($input->flag(0) == '-q' || $input->flag(0) == '--quiet'); // if quiet flag
3439

35-
if($input->flag(0) == '-h' || $input->flag(0) == '--help')
40+
if ($input->flag(0) == '-h' || $input->flag(0) == '--help') {
3641
$this->displayCommandHelp($input, $output, $app);
42+
}
3743
}
3844

3945
/**
40-
* display help for a given command
46+
* display help for a given command.
4147
*
42-
* @param InputInterface $input
48+
* @param InputInterface $input
4349
* @param OutputInterface $output
44-
* @param Conso $app
50+
* @param Conso $app
51+
*
4552
* @return void
4653
*/
4754
protected function displayCommandHelp($input, $output, $app)
4855
{
4956
$name = $app->activeCommand['name'];
5057
$help = $app->activeCommand['help'];
5158

52-
$output->writeLn("\n help for [" . $name . "] command:\n\n", "yellow");
59+
$output->writeLn("\n help for [".$name."] command:\n\n", 'yellow');
5360

5461
$output->writeLn(" php conso $name:{sub command} {options}\n\n");
5562

56-
if(is_array($help) && count($help) > 0)
57-
{
58-
foreach($help as $key => $value)
59-
{
60-
$output->writeLn(" [". $key ."]\n\n", 'yellow');
63+
if (is_array($help) && count($help) > 0) {
64+
foreach ($help as $key => $value) {
65+
$output->writeLn(' ['.$key."]\n\n", 'yellow');
6166

62-
foreach($value as $a => $b)
63-
$output->writeLn(" " . $a . " : " . $b . "\n\n");
67+
foreach ($value as $a => $b) {
68+
$output->writeLn(' '.$a.' : '.$b."\n\n");
69+
}
6470
}
6571
}
6672
exit;
6773
}
68-
}
74+
}

0 commit comments

Comments
 (0)