Skip to content

Commit

Permalink
refactor: Rename phar occurrences into pharInfo (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Oct 8, 2023
1 parent 1869c8f commit e845387
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions src/Phar/PharDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,49 @@
final class PharDiff
{
private readonly ParagoniePharDiff $diff;
private readonly PharInfo $pharA;
private readonly PharInfo $pharB;
private readonly PharInfo $pharInfoA;
private readonly PharInfo $pharInfoB;

public function __construct(string $pathA, string $pathB)
{
$phars = array_map(
[$pharInfoA, $pharInfoB] = array_map(
static fn (string $path) => new PharInfo($path),
[$pathA, $pathB],
);

$this->pharA = $phars[0];
$this->pharB = $phars[1];
$this->pharInfoA = $pharInfoA;
$this->pharInfoB = $pharInfoB;

$diff = new ParagoniePharDiff(...$phars);
$diff = new ParagoniePharDiff($pharInfoA, $pharInfoB);
$diff->setVerbose(true);

$this->diff = $diff;
}

public function getPharA(): PharInfo
public function getPharInfoA(): PharInfo
{
return $this->pharA;
return $this->pharInfoA;
}

public function getPharB(): PharInfo
public function getPharInfoB(): PharInfo
{
return $this->pharB;
return $this->pharInfoB;
}

public function gitDiff(): ?string
{
return self::getDiff(
$this->pharA,
$this->pharB,
$this->pharInfoA,
$this->pharInfoB,
'git diff --no-index',
);
}

public function gnuDiff(): ?string
{
return self::getDiff(
$this->pharA,
$this->pharB,
$this->pharInfoA,
$this->pharInfoB,
'diff',
);
}
Expand All @@ -91,8 +91,8 @@ public function listChecksums(string $algo = 'sha384'): int
*/
public function listDiff(): array
{
$pharAFiles = self::collectFiles($this->pharA);
$pharBFiles = self::collectFiles($this->pharB);
$pharAFiles = self::collectFiles($this->pharInfoA);
$pharBFiles = self::collectFiles($this->pharInfoB);

return [
array_diff($pharAFiles, $pharBFiles),
Expand Down
15 changes: 8 additions & 7 deletions src/Pharaoh/PharDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

namespace KevinGH\Box\Pharaoh;

use KevinGH\Box\Phar\PharInfo;
use KevinGH\Box\PharInfo\IncompariblePhars;
use ParagonIE\ConstantTime\Hex;
use ParagonIE_Sodium_File;
Expand Down Expand Up @@ -77,18 +78,18 @@ class PharDiff
'yellow' => "\033[0;93m",
];

/** @var array<int, SafePhar> */
private array $phars = [];
/** @var array<int, PharInfo> */
private array $pharInfos = [];

private bool $verbose = false;

public function __construct(SafePhar $pharA, SafePhar $pharB)
public function __construct(PharInfo $pharInfoA, PharInfo $pharInfoB)
{
if ($pharA->hasPubKey() || $pharB->hasPubKey()) {
if ($pharInfoA->hasPubKey() || $pharInfoB->hasPubKey()) {
throw IncompariblePhars::signedPhars();
}

$this->phars = [$pharA, $pharB];
$this->pharInfos = [$pharInfoA, $pharInfoB];
}

/**
Expand Down Expand Up @@ -208,8 +209,8 @@ public function listChecksums(string $algo = 'sha384'): int
{
[$pharA, $pharB] = $this->hashChildren(
$algo,
$this->phars[0]->getTmp(),
$this->phars[1]->getTmp(),
$this->pharInfos[0]->getTmp(),
$this->pharInfos[1]->getTmp(),
);

$diffs = 0;
Expand Down
1 change: 0 additions & 1 deletion tests/Console/Command/DiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use function ob_get_clean;
use function ob_start;
use function realpath;
use const PHP_VERSION_ID;

/**
* @covers \KevinGH\Box\Console\Command\Diff
Expand Down

0 comments on commit e845387

Please sign in to comment.