Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
lotfio committed Aug 4, 2020
1 parent 236be7d commit bd8b68f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Conso/CommandLinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private function linkFlags(array $flags, array $reserved = []): void
}

/**
* check flags before link
* check flags before link.
*
* @return void
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Conso/ConsoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ trait ConsoTrait
protected $commandsNamespace = 'Conso\\Commands';

/**
* built in commands
* built in commands.
*
* @var boolean
* @var bool
*/
protected $builtInCommands = true;

Expand Down Expand Up @@ -210,11 +210,11 @@ public function call(string $command): void
}

/**
* disable built in commands
* disable built in commands.
*
* @return void
*/
public function disableBuiltInCommands() : void
public function disableBuiltInCommands(): void
{
$this->builtInCommands = false;
}
Expand All @@ -226,7 +226,7 @@ public function disableBuiltInCommands() : void
*/
public function loadBuildInCommands()
{
if(!$this->output->isTestMode() && $this->builtInCommands == true) {
if (!$this->output->isTestMode() && $this->builtInCommands == true) {
$conso = $this;
require_once dirname(__DIR__, 2).'/commands.php';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Input implements InputInterface
'-q', '--quiet',
'--ansi', '--no-ansi',
'-n', '--no-interaction',
'-vv', '--verbose'
'-vv', '--verbose',
];

/**
Expand Down
16 changes: 9 additions & 7 deletions src/Conso/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class Output implements OutputInterface
private $testMode = false;

/**
* verbosity
* verbosity.
*
* @var boolean
* @var bool
*/
public $verbosity = false;

Expand Down Expand Up @@ -85,8 +85,9 @@ public function writeLn(string $line, string $color = 'white', string $bg = 'tra
{
$str = $this->lineFormatter($line, $color, $bg, $bold);

if($this->isHttp())
if ($this->isHttp()) {
return print nl2br($str);
}

return ($this->testMode) ? $str : fwrite(STDOUT, $str, strlen($str));
}
Expand Down Expand Up @@ -155,6 +156,7 @@ public function exception(\Exception $e): bool
$this->writeLn(" {$e->getMessage()}", 'white', 'red');
$this->writeLn(str_repeat(' ', $max - strlen($e->getMessage()))."\n", 'white', 'red');
$this->writeLn(str_repeat(' ', $max + 6)."\n", 'white', 'red');

return 0;
}

Expand Down Expand Up @@ -196,7 +198,7 @@ public function disableAnsi(): void
}

/**
* enabling verbosity
* enabling verbosity.
*
* @return void
*/
Expand Down Expand Up @@ -228,13 +230,13 @@ public function isTestMode(): bool
}

/**
* check if request is http
* check if request is http.
*
* @return boolean
* @return bool
*/
public function isHttp(): bool
{
return (php_sapi_name() !== 'cli');
return php_sapi_name() !== 'cli';
}

/**
Expand Down
16 changes: 6 additions & 10 deletions tests/Unit/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,36 @@ public function testOutputWriteLn()
}

/**
* test output with no verbosity
* test output with no verbosity.
*
* @return void
*/
public function testOutputNoVerbosity()
{
try{
try {
throw new \Exception('test exception');
}catch(\Exception $e)
{
} catch (\Exception $e) {
$this->assertFalse(
$this->output->exception($e)
);
}

}

/**
* test output with verbosity
* test output with verbosity.
*
* @return void
*/
public function testOutputVerbosity()
{
$this->output->enableVerbosity(); // enable verbosity (dev mode)

try{
try {
throw new \Exception('test exception');
}catch(\Exception $e)
{
} catch (\Exception $e) {
$this->assertTrue(
$this->output->exception($e)
);
}

}
}

0 comments on commit bd8b68f

Please sign in to comment.