-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathProcessResult.php
More file actions
60 lines (50 loc) · 1.39 KB
/
ProcessResult.php
File metadata and controls
60 lines (50 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Rector\ValueObject;
use Rector\ValueObject\Error\SystemError;
use Rector\ValueObject\Reporting\FileDiff;
use Webmozart\Assert\Assert;
final class ProcessResult
{
/**
* @param SystemError[] $systemErrors
* @param FileDiff[] $fileDiffs
*/
public function __construct(
private array $systemErrors,
private readonly array $fileDiffs,
private readonly int $totalChanged
) {
Assert::allIsInstanceOf($systemErrors, SystemError::class);
Assert::allIsInstanceOf($fileDiffs, FileDiff::class);
}
/**
* @return SystemError[]
*/
public function getSystemErrors(): array
{
return $this->systemErrors;
}
/**
* @return FileDiff[]
*/
public function getFileDiffs(bool $onlyWithChanges = true): array
{
if ($onlyWithChanges) {
return array_filter($this->fileDiffs, fn (FileDiff $fileDiff): bool => $fileDiff->getDiff() !== '');
}
return $this->fileDiffs;
}
/**
* @param SystemError[] $systemErrors
*/
public function addSystemErrors(array $systemErrors): void
{
Assert::allIsInstanceOf($systemErrors, SystemError::class);
$this->systemErrors = [...$this->systemErrors, ...$systemErrors];
}
public function getTotalChanged(): int
{
return $this->totalChanged;
}
}