Passed
Push — master ( 75052b...8ecf83 )
by Dmitri
01:50
created

BookCreated   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Domain\Event;
6
7
use App\Domain\Model\AuthorId;
8
use App\Domain\Model\BookId;
9
use DateTimeInterface;
10
use JsonSerializable;
11
12
final class BookCreated implements JsonSerializable
13
{
14
    private $bookId;
15
    private $authorId;
16
    private $title;
17
    private $occurredOn;
18
19
    public function __construct(BookId $bookId, AuthorId $authorId, string $title, DateTimeInterface $occurredOn)
20
    {
21
        $this->bookId = (string) $bookId;
22
        $this->authorId = (string) $authorId;
23
        $this->title = $title;
24
        $this->occurredOn = $occurredOn;
25
    }
26
27
    public function bookId(): BookId
28
    {
29
        return BookId::fromString($this->bookId);
30
    }
31
32
    public function authorId(): AuthorId
33
    {
34
        return AuthorId::fromString($this->authorId);
35
    }
36
37
    public function title(): string
38
    {
39
        return $this->title;
40
    }
41
42
    public function occurredOn(): DateTimeInterface
43
    {
44
        return $this->occurredOn;
45
    }
46
47
    public function jsonSerialize(): array
48
    {
49
        return get_object_vars($this);
50
    }
51
}
52