Board::getProfile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
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;
15
16
use Aggrego\DataDomainBoard\Board\Events\BoardCreatedEvent;
17
use Aggrego\DataDomainBoard\Board\Prototype\Metadata;
18
use Aggrego\Domain\Board\Board as DomainBoard;
19
use Aggrego\Domain\Board\Key;
20
use Aggrego\Domain\Board\Uuid;
21
use Aggrego\Domain\Profile\Profile;
22
use Aggrego\EventConsumer\Event;
23
use Aggrego\EventConsumer\Shared\Events;
24
25
class Board implements DomainBoard
26
{
27
    /** @var Events */
28
    protected $events;
29
30
    /** @var Uuid */
31
    private $uuid;
32
33
    /** @var Key */
34
    private $key;
35
36
    /** @var Profile */
37
    private $profile;
38
39
    /** @var Metadata */
40
    private $metadata;
41
42
    public function __construct(Uuid $uuid, Key $key, Profile $profile, Metadata $metadata, ?Uuid $parentUuid)
43
    {
44
        $this->uuid = $uuid;
45
        $this->key = $key;
46
        $this->profile = $profile;
47
        $this->metadata = $metadata;
48
        $this->events = new Events();
49
        $this->pushEvent(BoardCreatedEvent::build($uuid, $key, $profile, $metadata, $parentUuid));
50
    }
51
52
    public function getUuid(): Uuid
53
    {
54
        return $this->uuid;
55
    }
56
57
    public function getProfile(): Profile
58
    {
59
        return $this->profile;
60
    }
61
62
    public function getKey(): Key
63
    {
64
        return $this->key;
65
    }
66
67
    public function getMetadata(): Metadata
68
    {
69
        return $this->metadata;
70
    }
71
72
    public function pullEvents(): Events
73
    {
74
        $list = $this->events;
75
        $this->events = new Events();
76
        return $list;
77
    }
78
79
    protected function pushEvent(Event $event): void
80
    {
81
        $this->events->add($event);
82
    }
83
}
84