Post   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 62
ccs 15
cts 15
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getDate() 0 3 1
A __construct() 0 5 1
A getId() 0 3 1
A jsonSerialize() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Model\Post;
6
7
use DateTimeInterface;
8
use JsonSerializable;
9
10
final class Post implements JsonSerializable
11
{
12
    /**
13
     * @var int
14
     */
15
    private int $id;
16
17
    /**
18
     * @var string
19
     */
20
    private string $title;
21
22
    /**
23
     * @var DateTimeInterface
24
     */
25
    private DateTimeInterface $date;
26
27
    /**
28
     * @param int $id
29
     * @param string $title
30
     * @param DateTimeInterface $date
31
     */
32 11
    public function __construct(int $id, string $title, DateTimeInterface $date)
33
    {
34 11
        $this->id = $id;
35 11
        $this->title = $title;
36 11
        $this->date = $date;
37
    }
38
39
    /**
40
     * @return int
41
     */
42 3
    public function getId(): int
43
    {
44 3
        return $this->id;
45
    }
46
47
    /**
48
     * @return string
49
     */
50 3
    public function getTitle(): string
51
    {
52 3
        return $this->title;
53
    }
54
55
    /**
56
     * @return DateTimeInterface
57
     */
58 3
    public function getDate(): DateTimeInterface
59
    {
60 3
        return $this->date;
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66 7
    public function jsonSerialize(): array
67
    {
68 7
        return [
69 7
            'id' => $this->id,
70 7
            'title' => $this->title,
71 7
            'date' => $this->date,
72 7
        ];
73
    }
74
}
75