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\TransformBoard; |
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\Board\Uuid as BoardUuid; |
21
|
|
|
use Ramsey\Uuid\Uuid as RamseyUuid; |
22
|
|
|
|
23
|
|
|
class Command implements ConsumerCommand |
24
|
|
|
{ |
25
|
|
|
/** @var Uuid */ |
26
|
|
|
private $uuid; |
27
|
|
|
|
28
|
|
|
/** @var BoardUuid */ |
29
|
|
|
private $boardUuid; |
30
|
|
|
|
31
|
|
|
/** @var Key */ |
32
|
|
|
private $key; |
33
|
|
|
|
34
|
|
|
public function __construct(string $boardUuid, array $key) |
35
|
|
|
{ |
36
|
|
|
$this->boardUuid = new BoardUuid($boardUuid); |
37
|
|
|
$this->key = new Key($key); |
38
|
|
|
$this->uuid = new Uuid( |
39
|
|
|
RamseyUuid::uuid5( |
|
|
|
|
40
|
|
|
RamseyUuid::NAMESPACE_DNS, |
41
|
|
|
serialize($key) . $boardUuid |
42
|
|
|
)->toString() |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getBoardUuid(): BoardUuid |
47
|
|
|
{ |
48
|
|
|
return $this->boardUuid; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getKey(): Key |
52
|
|
|
{ |
53
|
|
|
return $this->key; |
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
|
|
|
'board_uuid' => $this->boardUuid->getValue(), |
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.