1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2017 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Component\Server\Command\Client; |
15
|
|
|
|
16
|
|
|
use OAuth2Framework\Component\Server\Command\CommandWithDataTransporter; |
17
|
|
|
use OAuth2Framework\Component\Server\DataTransporter; |
18
|
|
|
use OAuth2Framework\Component\Server\Model\Client\ClientId; |
19
|
|
|
use OAuth2Framework\Component\Server\Model\DataBag\DataBag; |
20
|
|
|
use OAuth2Framework\Component\Server\Model\UserAccount\UserAccountId; |
21
|
|
|
|
22
|
|
|
final class CreateClientCommand extends CommandWithDataTransporter |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var ClientId |
26
|
|
|
*/ |
27
|
|
|
private $clientId; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var DataBag |
31
|
|
|
*/ |
32
|
|
|
private $parameters; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var UserAccountId|null |
36
|
|
|
*/ |
37
|
|
|
private $userAccountId; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* CreateClientCommand constructor. |
41
|
|
|
* |
42
|
|
|
* @param ClientId $clientId |
43
|
|
|
* @param null|UserAccountId $userAccountId |
44
|
|
|
* @param DataBag $parameters |
45
|
|
|
* @param null|DataTransporter $dataTransporter |
46
|
|
|
*/ |
47
|
|
|
protected function __construct(ClientId $clientId, ? UserAccountId $userAccountId, DataBag $parameters, ? DataTransporter $dataTransporter) |
48
|
|
|
{ |
49
|
|
|
$this->clientId = $clientId; |
50
|
|
|
$this->parameters = $parameters; |
51
|
|
|
$this->userAccountId = $userAccountId; |
52
|
|
|
parent::__construct($dataTransporter); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param ClientId $clientId |
57
|
|
|
* @param UserAccountId|null $userAccountId |
58
|
|
|
* @param DataBag $parameters |
59
|
|
|
* @param DataTransporter|null $dataTransporter |
60
|
|
|
* |
61
|
|
|
* @return CreateClientCommand |
62
|
|
|
*/ |
63
|
|
|
public static function create(ClientId $clientId, ? UserAccountId $userAccountId, DataBag $parameters, ? DataTransporter $dataTransporter): CreateClientCommand |
64
|
|
|
{ |
65
|
|
|
return new self($clientId, $userAccountId, $parameters, $dataTransporter); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return ClientId |
70
|
|
|
*/ |
71
|
|
|
public function getClientId(): ClientId |
72
|
|
|
{ |
73
|
|
|
return $this->clientId; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return DataBag |
78
|
|
|
*/ |
79
|
|
|
public function getParameters(): DataBag |
80
|
|
|
{ |
81
|
|
|
return $this->parameters; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return UserAccountId|null |
86
|
|
|
*/ |
87
|
|
|
public function getUserAccountId(): ? UserAccountId |
88
|
|
|
{ |
89
|
|
|
return $this->userAccountId; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|