1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* This file is part of the Aggrego. |
5
|
|
|
* (c) Tomasz Kunicki <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types = 1); |
13
|
|
|
|
14
|
|
|
namespace Aggrego\Domain\Api\Command\CreateBoard; |
15
|
|
|
|
16
|
|
|
use Aggrego\CommandConsumer\Command as ConsumerCommand; |
17
|
|
|
use Aggrego\CommandConsumer\Uuid; |
18
|
|
|
use Aggrego\CommandConsumer\Version; |
19
|
|
|
use Aggrego\Domain\Board\Key; |
20
|
|
|
use Aggrego\Domain\Profile\Profile; |
21
|
|
|
use Ramsey\Uuid\Uuid as RamseyUuid; |
22
|
|
|
|
23
|
|
|
class Command implements ConsumerCommand |
24
|
|
|
{ |
25
|
|
|
/** @var Uuid */ |
26
|
|
|
private $uuid; |
27
|
|
|
|
28
|
|
|
/** @var Key */ |
29
|
|
|
private $key; |
30
|
|
|
|
31
|
|
|
/** @var Profile */ |
32
|
|
|
private $profile; |
33
|
|
|
|
34
|
|
|
public function __construct(array $key, string $profileName, string $versionNumber) |
35
|
|
|
{ |
36
|
|
|
$this->key = new Key($key); |
37
|
|
|
$this->profile = Profile::createFromParts($profileName, $versionNumber); |
38
|
|
|
$this->uuid = new Uuid( |
39
|
|
|
RamseyUuid::uuid5( |
|
|
|
|
40
|
|
|
RamseyUuid::NAMESPACE_DNS, |
41
|
|
|
serialize($key) . $this->profile |
42
|
|
|
)->toString() |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getKey(): Key |
47
|
|
|
{ |
48
|
|
|
return $this->key; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getProfile(): Profile |
52
|
|
|
{ |
53
|
|
|
return $this->profile; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getUuid(): Uuid |
57
|
|
|
{ |
58
|
|
|
return $this->uuid; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getVersion(): Version |
62
|
|
|
{ |
63
|
|
|
return new Version('1'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getPayload(): array |
67
|
|
|
{ |
68
|
|
|
return [ |
69
|
|
|
'uuid' => $this->getUuid()->getValue(), |
70
|
|
|
'version' => $this->getVersion()->getValue(), |
71
|
|
|
'key' => $this->key->getValue(), |
72
|
|
|
'profile' => (string)$this->profile, |
73
|
|
|
]; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.