-
-
Notifications
You must be signed in to change notification settings - Fork 336
/
SystemError.php
70 lines (59 loc) · 1.65 KB
/
SystemError.php
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
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
namespace Rector\Core\ValueObject\Error;
use Rector\Parallel\ValueObject\Name;
use Symplify\EasyParallel\Contract\SerializableInterface;
final class SystemError implements SerializableInterface
{
public function __construct(
private readonly string $message,
private readonly string|null $relativeFilePath = null,
private readonly int|null $line = null,
private readonly string|null $rectorClass = null
) {
}
public function getMessage(): string
{
return $this->message;
}
public function getFile(): string|null
{
return $this->relativeFilePath;
}
public function getLine(): int|null
{
return $this->line;
}
public function getFileWithLine(): string
{
return $this->relativeFilePath . ':' . $this->line;
}
/**
* @return array{message: string, relative_file_path: string|null, line: int|null, rector_class: string|null}
*/
public function jsonSerialize(): array
{
return [
Name::MESSAGE => $this->message,
Name::RELATIVE_FILE_PATH => $this->relativeFilePath,
Name::LINE => $this->line,
Name::RECTOR_CLASS => $this->rectorClass,
];
}
/**
* @param mixed[] $json
*/
public static function decode(array $json): SerializableInterface
{
return new self(
$json[Name::MESSAGE],
$json[Name::RELATIVE_FILE_PATH],
$json[Name::LINE],
$json[Name::RECTOR_CLASS]
);
}
public function getRectorClass(): ?string
{
return $this->rectorClass;
}
}