-
Notifications
You must be signed in to change notification settings - Fork 1
/
ActionError.php
60 lines (48 loc) · 1.66 KB
/
ActionError.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
<?php
declare(strict_types=1);
namespace BigGive\Identity\Application\Actions;
use JsonSerializable;
class ActionError implements JsonSerializable
{
public const string BAD_REQUEST = 'BAD_REQUEST';
public const string INSUFFICIENT_PRIVILEGES = 'INSUFFICIENT_PRIVILEGES';
public const string NOT_ALLOWED = 'NOT_ALLOWED';
public const string NOT_IMPLEMENTED = 'NOT_IMPLEMENTED';
public const string RESOURCE_NOT_FOUND = 'RESOURCE_NOT_FOUND';
public const string SERVER_ERROR = 'SERVER_ERROR';
public const string UNAUTHENTICATED = 'UNAUTHENTICATED';
public const string VALIDATION_ERROR = 'VALIDATION_ERROR';
public const string VERIFICATION_ERROR = 'VERIFICATION_ERROR';
public const string DUPLICATE_EMAIL_ADDRESS_WITH_PASSWORD = 'DUPLICATE_EMAIL_ADDRESS_WITH_PASSWORD';
public function __construct(
private string $type,
private string $description,
private ?array $trace = null,
private ?string $htmlDescription = null,
) {
}
public function jsonSerialize(): mixed
{
$payload = [
'type' => $this->type,
'description' => $this->description,
];
if ($this->trace !== null) {
$payload['trace'] = $this->trace;
}
if ($this->htmlDescription !== null) {
$payload['htmlDescription'] = $this->htmlDescription;
}
return $payload;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function setDescription(?string $description = null): self
{
$this->description = $description;
return $this;
}
}