Comment::setPost()   A
last analyzed

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
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Blog\Entity;
6
7
use App\Blog\Comment\CommentRepository;
8
use App\Blog\Comment\Scope\PublicScope;
9
use App\User\User;
10
use Cycle\Annotated\Annotation\Column;
0 ignored issues
show
Bug introduced by
The type Cycle\Annotated\Annotation\Column was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Cycle\Annotated\Annotation\Entity;
0 ignored issues
show
Bug introduced by
The type Cycle\Annotated\Annotation\Entity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Cycle\Annotated\Annotation\Relation\BelongsTo;
0 ignored issues
show
Bug introduced by
The type Cycle\Annotated\Annotation\Relation\BelongsTo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Cycle\Annotated\Annotation\Table\Index;
0 ignored issues
show
Bug introduced by
The type Cycle\Annotated\Annotation\Table\Index was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Cycle\ORM\Entity\Behavior;
0 ignored issues
show
Bug introduced by
The type Cycle\ORM\Entity\Behavior was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use DateTimeImmutable;
16
17
#[Entity(
18
    repository: CommentRepository::class,
19
    scope: PublicScope::class
20
)]
21
#[Index(columns: ['public', 'published_at'])]
22
#[Behavior\CreatedAt(field: 'created_at', column: 'created_at')]
23
#[Behavior\UpdatedAt(field: 'updated_at', column: 'updated_at')]
24
#[Behavior\SoftDelete(field: 'deleted_at', column: 'deleted_at')]
25
class Comment
26
{
27
    #[Column(type: 'primary')]
28
    private ?int $id = null;
29
30
    #[Column(type: 'bool', default: 'false', typecast: 'bool')]
31
    private bool $public = false;
32
33
    #[Column(type: 'text')]
34
    private string $content;
35
36
    #[Column(type: 'datetime')]
37
    private DateTimeImmutable $created_at;
38
39
    #[Column(type: 'datetime')]
40
    private DateTimeImmutable $updated_at;
41
42
    #[Column(type: 'datetime', nullable: true)]
43
    private ?DateTimeImmutable $published_at = null;
44
45
    #[Column(type: 'datetime', nullable: true)]
46
    private ?DateTimeImmutable $deleted_at = null;
47
48
    #[BelongsTo(target: User::class, nullable: false, load: 'eager')]
49
    private ?User $user = null;
50
    private ?int $user_id = null;
0 ignored issues
show
introduced by
The private property $user_id is not used, and could be removed.
Loading history...
51
52
    #[BelongsTo(target: Post::class, nullable: false)]
53
    private ?Post $post = null;
54
    private ?int $post_id = null;
0 ignored issues
show
introduced by
The private property $post_id is not used, and could be removed.
Loading history...
55
56
    public function __construct(string $content)
57
    {
58
        $this->content = $content;
59
        $this->created_at = new DateTimeImmutable();
60
        $this->updated_at = new DateTimeImmutable();
61
    }
62
63
    public function getId(): ?int
64
    {
65
        return $this->id;
66
    }
67
68
    public function getContent(): string
69
    {
70
        return $this->content;
71
    }
72
73
    public function setContent(string $content): void
74
    {
75
        $this->content = $content;
76
    }
77
78
    public function isPublic(): bool
79
    {
80
        return $this->public;
81
    }
82
83
    public function setPublic(bool $public): void
84
    {
85
        $this->public = $public;
86
    }
87
88
    public function getCreatedAt(): DateTimeImmutable
89
    {
90
        return $this->created_at;
91
    }
92
93
    public function getUpdatedAt(): DateTimeImmutable
94
    {
95
        return $this->updated_at;
96
    }
97
98
    public function getDeletedAt(): ?DateTimeImmutable
99
    {
100
        return $this->deleted_at;
101
    }
102
103
    public function setUser(User $user): void
104
    {
105
        $this->user = $user;
106
    }
107
108
    public function getUser(): ?User
109
    {
110
        return $this->user;
111
    }
112
113
    public function setPost(Post $post): void
114
    {
115
        $this->post = $post;
116
    }
117
118
    public function getPost(): ?Post
119
    {
120
        return $this->post;
121
    }
122
123
    public function getPublishedAt(): ?DateTimeImmutable
124
    {
125
        return $this->published_at;
126
    }
127
128
    public function setPublishedAt(?DateTimeImmutable $published_at): void
129
    {
130
        $this->published_at = $published_at;
131
    }
132
}
133