Skip to content

Commit 595a5b7

Browse files
dimtrovichadhocore
authored andcommitted
refactor: change twoColumnsDetail to justify
1 parent eed7622 commit 595a5b7

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,15 +613,15 @@ $writer->table([
613613
// In future we may support styling a column by its name!
614614
```
615615

616-
#### Two columns detail (Display setting)
616+
#### Justify content (Display setting)
617617

618-
If you want to display certain configurations (from your .env file for example) a bit like Laravel does (via the php artisan `about` command) you can use the `twoColumnDetail` method.
618+
If you want to display certain configurations (from your .env file for example) a bit like Laravel does (via the `php artisan about` command) you can use the `justify` method.
619619

620620
```php
621-
$writer->twoColumnDetail('Environment');
622-
$writer->twoColumnDetail('PHP Version', PHP_VERSION);
623-
$writer->twoColumnDetail('App Version', '1.0.0');
624-
$writer->twoColumnDetail('Locale', 'en');
621+
$writer->justify('Environment');
622+
$writer->justify('PHP Version', PHP_VERSION);
623+
$writer->justify('App Version', '1.0.0');
624+
$writer->justify('Locale', 'en');
625625
```
626626

627627
Gives something like:
@@ -636,8 +636,8 @@ Locale .......................................... en
636636
You can use the `sep` parameter to define the separator to use.
637637

638638
```php
639-
$writer->twoColumnDetail('Environment', '', ['sep' => '-']);
640-
$writer->twoColumnDetail('PHP Version', PHP_VERSION);
639+
$writer->justify('Environment', '', ['sep' => '-']);
640+
$writer->justify('PHP Version', PHP_VERSION);
641641
```
642642

643643
Gives something like:
@@ -650,11 +650,11 @@ PHP Version .................................. 8.1.4
650650
In addition, the text color, the background color and the thickness of the two texts can be defined via the 3rd argument of this method.
651651

652652
```php
653-
$writer->twoColumnDetail('Cache Enable', 'true', [
653+
$writer->justify('Cache Enable', 'true', [
654654
'first' => ['fg' => Ahc\Cli\Output\Color::CYAN], // style of the key
655655
'second' => ['fg' => Ahc\Cli\Output\Color::GREEN], // style of the value
656656
]);
657-
$writer->twoColumnDetail('Debug Mode', 'false', [
657+
$writer->justify('Debug Mode', 'false', [
658658
'first' => ['fg' => Ahc\Cli\Output\Color::CYAN], // style of the key
659659
'second' => ['fg' => Ahc\Cli\Output\Color::RED], // style of the value
660660
]);

src/Output/Writer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public function table(array $rows, array $styles = []): self
313313
*
314314
* @return self
315315
*/
316-
public function twoColumnDetail(string $first, ?string $second = null, array $options = []): self
316+
public function justify(string $first, ?string $second = null, array $options = []): self
317317
{
318318
$options = [
319319
'first' => ($options['first'] ?? []) + ['bg' => null, 'fg' => Color::WHITE, 'bold' => 0],

tests/Output/WriterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ public function test_terminal()
118118
$this->assertInstanceOf(Terminal::class, (new Writer)->terminal());
119119
}
120120

121-
public function test_two_column_detail()
121+
public function test_justify()
122122
{
123123
$w = new Writer(static::$ou);
124124

125-
$w->twoColumnDetail('PHP Version', PHP_VERSION, [
125+
$w->justify('PHP Version', PHP_VERSION, [
126126
'sep' => '-'
127127
]);
128128

0 commit comments

Comments
 (0)