BoardCreatedEvent::build()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 1
nop 5
dl 0
loc 16
rs 9.8666
c 0
b 0
f 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\DataDomainBoard\Board\Events;
15
16
use Aggrego\DataDomainBoard\Board\Prototype\Metadata;
17
use Aggrego\Domain\Board\Key;
18
use Aggrego\Domain\Board\Uuid;
19
use Aggrego\Domain\Profile\Profile;
20
use Aggrego\EventConsumer\Event\CreatedAt;
21
use Aggrego\EventConsumer\Event\Domain;
22
use Aggrego\EventConsumer\Event\Name;
23
use Aggrego\EventConsumer\Event\Version;
24
use Aggrego\EventConsumer\Shared\Event;
25
use DateTimeImmutable;
26
27
class BoardCreatedEvent extends Event
28
{
29
    private const DOMAIN_NAME = 'board.data_board';
30
31
    public static function build(Uuid $uuid, Key $key, Profile $profile, Metadata $metadata, ?Uuid $parentUuid): self
32
    {
33
        return new self(
34
            Domain::build(
35
                self::DOMAIN_NAME,
36
                $uuid->getValue()
37
            ),
38
            new Name(self::class),
39
            new CreatedAt(new DateTimeImmutable()),
40
            new Version('1.0.0.0'),
41
            [
42
                'uuid' => $uuid->getValue(),
43
                'key' => $key->getValue(),
44
                'profile' => $profile->__toString(),
45
                'metadata' => $metadata->getData()->getValue(),
46
                'parent_uuid' => $parentUuid ? $parentUuid->getValue() : null,
47
            ]
48
        );
49
    }
50
}
51