Completed
Push — v4.0 ( 989be1...ff495d )
by Masiukevich
02:21
created

StoredAggregateEventStream::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 9
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
 * Event Sourcing implementation.
5
 *
6
 * @author  Maksim Masiukevich <[email protected]>
7
 * @license MIT
8
 * @license https://opensource.org/licenses/MIT
9
 */
10
11
declare(strict_types = 1);
12
13
namespace ServiceBus\EventSourcing\EventStream\Store;
14
15
/**
16
 * Aggregate event stream data.
17
 *
18
 * @psalm-readonly
19
 */
20
final class StoredAggregateEventStream
21
{
22
    /**
23
     * Aggregate id.
24
     */
25
    public string $aggregateId;
26
27
    /**
28
     * Aggregate id class.
29
     *
30
     * @psalm-var class-string<\ServiceBus\EventSourcing\AggregateId>
31
     */
32
    public string $aggregateIdClass;
33
34
    /**
35
     * Aggregate class.
36
     *
37
     * @psalm-var class-string<\ServiceBus\EventSourcing\Aggregate>
38
     */
39
    public string $aggregateClass;
40
41
    /**
42
     * Stored events data.
43
     *
44
     * @psalm-var array<int, \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent>
45
     *
46
     * @var \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent[]
47
     */
48
    public array $storedAggregateEvents;
49
50
    /**
51
     * Stream created at datetime.
52
     */
53
    public string $createdAt;
54
55
    /**
56
     * Stream closed at datetime.
57
     */
58
    public ?string $closedAt = null;
59
60
    /**
61
     * @psalm-param class-string<\ServiceBus\EventSourcing\AggregateId> $aggregateIdClass
62
     * @psalm-param class-string<\ServiceBus\EventSourcing\Aggregate> $aggregateClass
63
     * @psalm-param array<int, \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent> $storedAggregateEvents
64
     *
65
     * @param \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent[] $storedAggregateEvents
66
     */
67 7
    public function __construct(
68
        string $aggregateId,
69
        string $aggregateIdClass,
70
        string $aggregateClass,
71
        array $storedAggregateEvents,
72
        string $createdAt,
73
        ?string $closedAt = null
74
    )
75
    {
76 7
        $this->aggregateId           = $aggregateId;
77 7
        $this->aggregateIdClass      = $aggregateIdClass;
78 7
        $this->aggregateClass        = $aggregateClass;
79 7
        $this->storedAggregateEvents = $storedAggregateEvents;
80 7
        $this->createdAt             = $createdAt;
81 7
        $this->closedAt              = $closedAt;
82 7
    }
83
}
84