-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRule.php
More file actions
117 lines (102 loc) · 3.1 KB
/
Copy pathRule.php
File metadata and controls
117 lines (102 loc) · 3.1 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
namespace Utopia\Migration\Resources\Domains;
use Utopia\Migration\Resource;
use Utopia\Migration\Transfer;
class Rule extends Resource
{
public function __construct(
string $id,
private readonly string $domain,
private readonly string $type,
private readonly string $trigger,
private readonly string $redirectUrl = '',
private readonly int $redirectStatusCode = 0,
private readonly string $deploymentResourceType = '',
private readonly string $deploymentResourceId = '',
private readonly string $deploymentVcsProviderBranch = '',
string $createdAt = '',
string $updatedAt = '',
) {
$this->id = $id;
$this->createdAt = $createdAt;
$this->updatedAt = $updatedAt;
}
/**
* @param array<string, mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
$array['id'],
$array['domain'],
$array['type'],
$array['trigger'] ?? 'manual',
(string) ($array['redirectUrl'] ?? ''),
(int) ($array['redirectStatusCode'] ?? 0),
(string) ($array['deploymentResourceType'] ?? ''),
(string) ($array['deploymentResourceId'] ?? ''),
(string) ($array['deploymentVcsProviderBranch'] ?? ''),
createdAt: $array['createdAt'] ?? '',
updatedAt: $array['updatedAt'] ?? '',
);
}
/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'domain' => $this->domain,
'type' => $this->type,
'trigger' => $this->trigger,
'redirectUrl' => $this->redirectUrl,
'redirectStatusCode' => $this->redirectStatusCode,
'deploymentResourceType' => $this->deploymentResourceType,
'deploymentResourceId' => $this->deploymentResourceId,
'deploymentVcsProviderBranch' => $this->deploymentVcsProviderBranch,
'createdAt' => $this->createdAt,
'updatedAt' => $this->updatedAt,
];
}
public static function getName(): string
{
return Resource::TYPE_RULE;
}
public function getGroup(): string
{
return Transfer::GROUP_DOMAINS;
}
public function getDomain(): string
{
return $this->domain;
}
public function getType(): string
{
return $this->type;
}
public function getTrigger(): string
{
return $this->trigger;
}
public function getRedirectUrl(): string
{
return $this->redirectUrl;
}
public function getRedirectStatusCode(): int
{
return $this->redirectStatusCode;
}
public function getDeploymentResourceType(): string
{
return $this->deploymentResourceType;
}
public function getDeploymentResourceId(): string
{
return $this->deploymentResourceId;
}
public function getDeploymentVcsProviderBranch(): string
{
return $this->deploymentVcsProviderBranch;
}
}