Passed
Push — master ( a76ba3...5b1507 )
by Tomasz
01:33
created

Command::getVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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(
0 ignored issues
show
Deprecated Code introduced by
The function Ramsey\Uuid\UuidInterface::toString() has been deprecated: In ramsey/uuid 4.0.0, this method will be replaced with the __toString() magic method, which is currently available in the Uuid concrete class. The new recommendation is to cast Uuid objects to string, rather than calling `toString()`. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

39
            /** @scrutinizer ignore-deprecated */ RamseyUuid::uuid5(

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.

Loading history...
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