-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathError.php
More file actions
82 lines (69 loc) · 1.67 KB
/
Error.php
File metadata and controls
82 lines (69 loc) · 1.67 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php declare(strict_types=1);
namespace MpApiClient\Checks\Entity;
use JsonSerializable;
use MpApiClient\Common\Util\JsonSerializeEntityTrait;
final class Error implements JsonSerializable
{
use JsonSerializeEntityTrait;
private string $code;
private string $attribute;
private string $value;
private string $msg;
/**
* @var string[]
*/
private array $articles;
/**
* @param string $code
* @param string $attribute
* @param string $value
* @param string $msg
* @param string[] $articles
*/
private function __construct(string $code, string $attribute, string $value, string $msg, array $articles)
{
$this->code = $code;
$this->attribute = $attribute;
$this->value = $value;
$this->msg = $msg;
$this->articles = $articles;
}
/**
* @param array<string, mixed> $data
*
* @internal
*/
public static function createFromApi(array $data): self
{
return new self(
(string) $data['code'],
(string) $data['attribute'],
(string) $data['value'],
(string) $data['msg'],
$data['articles'] ?? [],
);
}
public function getCode(): string
{
return $this->code;
}
public function getAttribute(): string
{
return $this->attribute;
}
public function getValue(): string
{
return $this->value;
}
public function getMsg(): string
{
return $this->msg;
}
/**
* @return string[]
*/
public function getArticles(): array
{
return $this->articles;
}
}