Passed
Pull Request — master (#49)
by
unknown
11:52
created

Comment::getPost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Blog\Entity;
4
5
use App\Entity\User;
6
use Cycle\Annotated\Annotation\Column;
7
use Cycle\Annotated\Annotation\Entity;
8
use Cycle\Annotated\Annotation\Relation\BelongsTo;
9
use Cycle\Annotated\Annotation\Table;
10
use Cycle\Annotated\Annotation\Table\Index;
11
use DateTimeImmutable;
12
13
/**
14
 * @Entity(
15
 *     mapper="App\Blog\Comment\CommentMapper",
16
 *     constrain="App\Blog\Comment\Scope\PublicScope"
17
 * )
18
 * @Table(
19
 *     indexes={
20
 *         @Index(columns={"public","publishedAt"})
21
 *     }
22
 * )
23
 */
24
class Comment
25
{
26
    /**
27
     * @Column(type="primary")
28
     * @var int
29
     */
30
    private $id;
31
32
    /**
33
     * @Column(type="bool", default="false")
34
     * @var bool
35
     */
36
    private $public;
37
38
    /**
39
     * @Column(type="text")
40
     * @var string
41
     */
42
    private $content;
43
44
    /**
45
     * @Column(type="datetime")
46
     * @var DateTimeImmutable
47
     */
48
    private $createdAt;
49
50
    /**
51
     * @Column(type="datetime")
52
     * @var DateTimeImmutable
53
     */
54
    private $updatedAt;
55
56
    /**
57
     * @Column(type="datetime", nullable=true)
58
     * @var DateTimeImmutable|null
59
     */
60
    private $publishedAt;
61
62
    /**
63
     * @Column(type="datetime", nullable=true)
64
     * @var DateTimeImmutable|null
65
     */
66
    private $deletedAt;
67
68
    /**
69
     * @BelongsTo(target="App\Entity\User", nullable=false, load="eager")
70
     * @var User|\Cycle\ORM\Promise\Reference
71
     */
72
    private $user;
73
74
    /**
75
     * @BelongsTo(target="App\Blog\Entity\Post", nullable=false)
76
     * @var Post|\Cycle\ORM\Promise\Reference
77
     */
78
    private $post;
79
80
    public function getId(): ?string
81
    {
82
        return $this->id;
83
    }
84
85
    public function getContent(): string
86
    {
87
        return $this->content;
88
    }
89
90
    public function setContent(string $content): void
91
    {
92
        $this->content = $content;
93
    }
94
95
    public function isPublic(): bool
96
    {
97
        return $this->public;
98
    }
99
100
    public function setPublic(bool $public): void
101
    {
102
        $this->public = $public;
103
    }
104
105
    public function getCreatedAt(): DateTimeImmutable
106
    {
107
        return $this->createdAt;
108
    }
109
110
    public function getUpdatedAt(): DateTimeImmutable
111
    {
112
        return $this->updatedAt;
113
    }
114
115
    public function getDeletedAt(): ?DateTimeImmutable
116
    {
117
        return $this->deletedAt;
118
    }
119
120
    public function setUser(User $user)
121
    {
122
        $this->user = $user;
123
    }
124
125
    public function getUser(): User
126
    {
127
        return $this->user;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->user could return the type Cycle\ORM\Promise\Reference which is incompatible with the type-hinted return App\Entity\User. Consider adding an additional type-check to rule them out.
Loading history...
128
    }
129
130
    public function setPost(Post $post)
131
    {
132
        $this->post = $post;
133
    }
134
135
    public function getPost(): Post
136
    {
137
        return $this->post;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->post could return the type Cycle\ORM\Promise\Reference which is incompatible with the type-hinted return App\Blog\Entity\Post. Consider adding an additional type-check to rule them out.
Loading history...
138
    }
139
140
    public function getPublishedAt(): ?DateTimeImmutable
141
    {
142
        return $this->publishedAt;
143
    }
144
145
    public function setPublishedAt(?DateTimeImmutable $publishedAt): void
146
    {
147
        $this->publishedAt = $publishedAt;
148
    }
149
}
150