Skip to content

Commit

Permalink
Right Align Numbers in Stats Table
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzweifel committed Oct 19, 2017
1 parent ccc0915 commit 3553409
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Commands/StatsListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Wnx\LaravelStats\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Helper\TableStyle;
use Wnx\LaravelStats\Services\StatisticsListService;

class StatsListCommand extends Command
Expand Down Expand Up @@ -31,7 +32,24 @@ public function handle(StatisticsListService $service)
{
$this->table(
$service->getHeaders(),
$service->getData()
$service->getData(),
'default',
$this->getColumnStyles()
);
}

protected function getColumnStyles()
{
$rightAlignment = new TableStyle();
$rightAlignment->setPadType(STR_PAD_LEFT);

return [
1 => $rightAlignment,
2 => $rightAlignment,
3 => $rightAlignment,
4 => $rightAlignment,
5 => $rightAlignment,
6 => $rightAlignment,
];
}
}

0 comments on commit 3553409

Please sign in to comment.