AggregateCreated::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 9
ccs 6
cts 6
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 ServiceBus\EventSourcing\AggregateId;
16
17
/**
18
 * New aggregate created.
19
 *
20
 * @psalm-immutable
21
 */
22
final class AggregateCreated
23
{
24
    /**
25
     * Aggregate identifier.
26
     *
27
     * @var string
28
     */
29
    public $id;
30
31
    /**
32
     * Aggregate identifier class.
33
     *
34
     * @psalm-var class-string<\ServiceBus\EventSourcing\AggregateId>
35
     *
36
     * @var string
37
     */
38
    public $idClass;
39
40
    /**
41
     * Aggregate class.
42
     *
43
     * @psalm-var class-string<\ServiceBus\EventSourcing\Aggregate>
44
     *
45
     * @var string
46
     */
47
    public $aggregateClass;
48
49
    /**
50
     * Operation datetime.
51
     *
52
     * @var \DateTimeImmutable
53
     */
54
    public $datetime;
55
56
    /**
57
     * @psalm-param class-string<\ServiceBus\EventSourcing\Aggregate> $aggregateClass
58
     */
59 10
    public function __construct(AggregateId $id, string $aggregateClass, \DateTimeImmutable $datetime)
60
    {
61
        /** @psalm-var class-string<\ServiceBus\EventSourcing\AggregateId> $idClass */
62 10
        $idClass = (string) \get_class($id);
63
64 10
        $this->id             = $id->toString();
65 10
        $this->idClass        = $idClass;
66 10
        $this->aggregateClass = $aggregateClass;
67 10
        $this->datetime       = $datetime;
68 10
    }
69
}
70