Skip to content

Commit

Permalink
refactor: Move the rendering of the PHAR version to PharInfoRenderer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Oct 21, 2023
1 parent f1c6086 commit 432128d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/Console/Command/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ private static function showPharInfo(

private static function showPharMeta(PharInfo $pharInfo, IO $io): void
{
$io->writeln(
sprintf(
'<comment>API Version:</comment> %s',
$pharInfo->getVersion(),
),
);
PharInfoRenderer::renderVersion($pharInfo, $io);

$io->newLine();

Expand Down
24 changes: 24 additions & 0 deletions src/Console/PharInfoRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ final class PharInfoRenderer

private const INDENT_SIZE = 2;

public static function renderVersion(PharInfo $pharInfo, IO $io): void
{
$io->writeln(
sprintf(
'<comment>API Version:</comment> %s',
$pharInfo->getVersion(),
),
);
}

public static function renderCompression(PharInfo $pharInfo, IO $io): void
{
$io->writeln(
Expand Down Expand Up @@ -131,6 +141,20 @@ public static function renderMetadata(PharInfo $pharInfo, IO $io): void
}
}

public static function renderTimestamp(PharInfo $pharInfo, IO $io): void
{
$timestamp = $pharInfo->getTimestamp();
$dateTime = (new DateTimeImmutable())->setTimestamp($timestamp);

$io->writeln(
sprintf(
'<comment>Timestamp:</comment> %s (%s)',
$timestamp,
$dateTime->format(DateTimeImmutable::ATOM),
),
);
}

public static function renderContentsSummary(PharInfo $pharInfo, IO $io): void
{
$count = array_filter($pharInfo->getFilesCompressionCount());
Expand Down

0 comments on commit 432128d

Please sign in to comment.