|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Aweapi\Openapi\Objects; |
|
6
|
|
|
|
|
7
|
|
|
use Aweapi\Openapi\Extensions; |
|
8
|
|
|
use Aweapi\Openapi\ValueObject; |
|
9
|
|
|
|
|
10
|
|
|
final class OAuthFlows extends ValueObject |
|
11
|
|
|
{ |
|
12
|
|
|
use Properties\OptionalExtensions; |
|
13
|
|
|
|
|
14
|
|
|
private $authorizationCode; |
|
15
|
|
|
|
|
16
|
|
|
private $clientCredentials; |
|
17
|
|
|
|
|
18
|
|
|
private $implicit; |
|
19
|
|
|
|
|
20
|
|
|
private $password; |
|
21
|
|
|
|
|
22
|
4 |
|
public function __construct( |
|
23
|
|
|
OAuthFlow $implicit = null, |
|
24
|
|
|
OAuthFlow $password = null, |
|
25
|
|
|
OAuthFlow $clientCredentials = null, |
|
26
|
|
|
OAuthFlow $authorizationCode = null, |
|
27
|
|
|
Extensions $extensions = null |
|
28
|
|
|
) { |
|
29
|
4 |
|
$this->implicit = $implicit; |
|
30
|
4 |
|
$this->password = $password; |
|
31
|
4 |
|
$this->clientCredentials = $clientCredentials; |
|
32
|
4 |
|
$this->authorizationCode = $authorizationCode; |
|
33
|
4 |
|
$this->extensions = $extensions; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
1 |
|
public function getAuthorizationCode(): OAuthFlow |
|
37
|
|
|
{ |
|
38
|
1 |
|
return $this->authorizationCode; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
1 |
|
public function getClientCredentials(): OAuthFlow |
|
42
|
|
|
{ |
|
43
|
1 |
|
return $this->clientCredentials; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
3 |
|
public function getImplicit(): OAuthFlow |
|
47
|
|
|
{ |
|
48
|
3 |
|
return $this->implicit; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
1 |
|
public function getPassword(): OAuthFlow |
|
52
|
|
|
{ |
|
53
|
1 |
|
return $this->password; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
4 |
|
public function hasAuthorizationCode(): bool |
|
57
|
|
|
{ |
|
58
|
4 |
|
return isset($this->authorizationCode); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
4 |
|
public function hasClientCredentials(): bool |
|
62
|
|
|
{ |
|
63
|
4 |
|
return isset($this->clientCredentials); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
4 |
|
public function hasImplicit(): bool |
|
67
|
|
|
{ |
|
68
|
4 |
|
return isset($this->implicit); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
4 |
|
public function hasPassword(): bool |
|
72
|
|
|
{ |
|
73
|
4 |
|
return isset($this->password); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
4 |
|
public function jsonSerialize(): ?array |
|
77
|
|
|
{ |
|
78
|
4 |
|
return $this->extendedProperties(parent::jsonSerialize()); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
4 |
|
protected function normalizeOptionalProperties(): array |
|
82
|
|
|
{ |
|
83
|
|
|
return [ |
|
84
|
4 |
|
'implicit' => $this->hasImplicit() ? $this->getImplicit()->jsonSerialize() : null, |
|
85
|
4 |
|
'password' => $this->hasPassword() ? $this->getPassword()->jsonSerialize() : null, |
|
86
|
4 |
|
'clientCredentials' => $this->hasClientCredentials() ? $this->getClientCredentials()->jsonSerialize() : null, |
|
87
|
4 |
|
'authorizationCode' => $this->hasAuthorizationCode() ? $this->getAuthorizationCode()->jsonSerialize() : null, |
|
88
|
|
|
]; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|