Issues (224)

src/Phar/PharDiff.php (4 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\Phar;
16
17
use Fidry\Console\IO;
0 ignored issues
show
The type Fidry\Console\IO was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use KevinGH\Box\Phar\Differ\DifferFactory;
19
use function array_map;
20
21
/**
22
 * @internal
23
 */
24
final class PharDiff
25
{
26
    private readonly PharInfo $pharInfoA;
27
    private readonly PharInfo $pharInfoB;
28
    private readonly DifferFactory $differFactory;
29
30
    public function __construct(string $pathA, string $pathB)
31
    {
32
        [$pharInfoA, $pharInfoB] = array_map(
33
            static fn (string $path) => new PharInfo($path),
34
            [$pathA, $pathB],
35
        );
36
37
        $this->pharInfoA = $pharInfoA;
0 ignored issues
show
The property pharInfoA is declared read-only in KevinGH\Box\Phar\PharDiff.
Loading history...
38
        $this->pharInfoB = $pharInfoB;
0 ignored issues
show
The property pharInfoB is declared read-only in KevinGH\Box\Phar\PharDiff.
Loading history...
39
40
        $this->differFactory = new DifferFactory();
0 ignored issues
show
The property differFactory is declared read-only in KevinGH\Box\Phar\PharDiff.
Loading history...
41
    }
42
43
    public function getPharInfoA(): PharInfo
44
    {
45
        return $this->pharInfoA;
46
    }
47
48
    public function getPharInfoB(): PharInfo
49
    {
50
        return $this->pharInfoB;
51
    }
52
53
    public function equals(): bool
54
    {
55
        return $this->pharInfoA->equals($this->pharInfoB);
56
    }
57
58
    public function diff(DiffMode $mode, string $checksumAlgorithm, IO $io): void
59
    {
60
        $this->differFactory
61
            ->create($mode, $checksumAlgorithm)
62
            ->diff(
63
                $this->pharInfoA,
64
                $this->pharInfoB,
65
                $io,
66
            );
67
    }
68
}
69