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

AggregateClosed::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
ccs 3
cts 3
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\Contract;
14
15
use function ServiceBus\Common\datetimeInstantiator;
16
use ServiceBus\EventSourcing\AggregateId;
17
18
/**
19
 * The aggregate (event stream) was marked as closed for modification.
20
 *
21
 * @psalm-readonly
22
 */
23
final class AggregateClosed
24
{
25
    /**
26
     * Aggregate identifier.
27
     */
28
    public string $id;
29
30
    /**
31
     * Aggregate identifier class.
32
     *
33
     * @psalm-var class-string<\ServiceBus\EventSourcing\AggregateId>
34
     */
35
    public string $idClass;
36
37
    /**
38
     * Aggregate class.
39
     *
40
     * @psalm-var class-string<\ServiceBus\EventSourcing\Aggregate>
41
     */
42
    public string $aggregateClass;
43
44
    /**
45
     * Operation datetime.
46
     */
47
    public \DateTimeImmutable $datetime;
48
49
    /**
50
     * @psalm-param class-string<\ServiceBus\EventSourcing\Aggregate> $aggregateClass
51
     */
52 1
    public function __construct(AggregateId $id, string $aggregateClass)
53
    {
54
        /** @psalm-var class-string<\ServiceBus\EventSourcing\AggregateId> $idClass */
55 1
        $idClass = (string) \get_class($id);
56
57 1
        $this->id             = $id->toString();
58 1
        $this->idClass        = $idClass;
59 1
        $this->aggregateClass = $aggregateClass;
60
61
        /** @var \DateTimeImmutable $currentDate */
62 1
        $currentDate = datetimeInstantiator('NOW');
63
64 1
        $this->datetime = $currentDate;
65 1
    }
66
}
67