1 | <?php |
||
2 | |||
3 | |||
4 | namespace Apie\OpenapiSchema\Spec; |
||
5 | |||
6 | use Apie\OpenapiSchema\Concerns\CompositeValueObjectWithExtension; |
||
7 | use Apie\OpenapiSchema\Exceptions\OAuthRequiresAuthorizationUrl; |
||
8 | use Apie\OpenapiSchema\Exceptions\OAuthRequiresTokenUrl; |
||
9 | use Apie\ValueObjects\ValueObjectInterface; |
||
10 | |||
11 | /** |
||
12 | * @see https://swagger.io/specification/#oauth-flows-object |
||
13 | */ |
||
14 | class OAuthFlows implements ValueObjectInterface |
||
15 | { |
||
16 | use CompositeValueObjectWithExtension; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
17 | |||
18 | /** |
||
19 | * @var OAuthFlow|null |
||
20 | */ |
||
21 | private $implicit; |
||
22 | |||
23 | /** |
||
24 | * @var OAuthFlow|null |
||
25 | */ |
||
26 | private $password; |
||
27 | |||
28 | /** |
||
29 | * @var OAuthFlow|null |
||
30 | */ |
||
31 | private $clientCredentials; |
||
32 | |||
33 | /** |
||
34 | * @var OAuthFlow|null |
||
35 | */ |
||
36 | private $authorizationCode; |
||
37 | |||
38 | private function __construct() |
||
39 | { |
||
40 | } |
||
41 | |||
42 | protected function validateProperties(): void |
||
43 | { |
||
44 | if ($this->implicit && null === $this->implicit->getAuthorizationUrl()) { |
||
45 | throw new OAuthRequiresAuthorizationUrl(); |
||
46 | } |
||
47 | if ($this->password && null === $this->password->getTokenUrl()) { |
||
48 | throw new OAuthRequiresTokenUrl(); |
||
49 | } |
||
50 | if ($this->clientCredentials && $this->clientCredentials->getTokenUrl()) { |
||
51 | throw new OAuthRequiresTokenUrl(); |
||
52 | } |
||
53 | if ($this->authorizationCode) { |
||
54 | if (null === $this->authorizationCode->getAuthorizationUrl()) { |
||
55 | throw new OAuthRequiresAuthorizationUrl(); |
||
56 | } |
||
57 | if (null === $this->authorizationCode->getTokenUrl()) { |
||
58 | throw new OAuthRequiresTokenUrl(); |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 |