-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathApple.php
More file actions
75 lines (67 loc) · 1.89 KB
/
Copy pathApple.php
File metadata and controls
75 lines (67 loc) · 1.89 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
<?php
namespace Utopia\Migration\Resources\Auth\OAuth2;
/**
* Apple OAuth2 provider. Bespoke shape — the credential is split across four
* fields. `serviceId`/`keyId`/`teamId` are readable on the source and
* migrated; `p8File` is write-only and must be re-entered on the destination.
*/
class Apple extends OAuth2Provider
{
public function __construct(
string $id,
bool $enabled,
private readonly string $serviceId = '',
private readonly string $keyId = '',
private readonly string $teamId = '',
string $createdAt = '',
string $updatedAt = '',
) {
parent::__construct($id, $enabled, $createdAt, $updatedAt);
}
/**
* @param array<string, mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
$array['id'],
(bool) ($array['enabled'] ?? false),
(string) ($array['serviceId'] ?? ''),
(string) ($array['keyId'] ?? ''),
(string) ($array['teamId'] ?? ''),
createdAt: $array['createdAt'] ?? '',
updatedAt: $array['updatedAt'] ?? '',
);
}
/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'enabled' => $this->enabled,
'serviceId' => $this->serviceId,
'keyId' => $this->keyId,
'teamId' => $this->teamId,
'createdAt' => $this->createdAt,
'updatedAt' => $this->updatedAt,
];
}
public static function getProviderKey(): string
{
return 'apple';
}
public function getServiceId(): string
{
return $this->serviceId;
}
public function getKeyId(): string
{
return $this->keyId;
}
public function getTeamId(): string
{
return $this->teamId;
}
}