Passed
Pull Request — master (#572)
by Dmitriy
01:35
created

Post::getId()   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
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Application\Blog\Entity\Post;
6
7
use App\Application\User\Entity\User;
8
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...
9
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...
10
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...
11
use DateTimeImmutable;
12
use Yiisoft\Security\Random;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Security\Random 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
14
#[Entity(repository: PostRepository::class)]
15
class Post
16
{
17
    #[Column(type: 'primary')]
18
    private ?int $id = null;
19
20
    #[Column(type: 'string(128)')]
21
    private string $slug;
22
23
    #[Column(type: 'string(255)', default: '')]
24
    private string $title = '';
25
26
    #[Column(type: 'int(11)', default: 0)]
27
    private int $status = 0;
28
29
    #[Column(type: 'string')]
30
    private string $content;
31
32
    #[Column(type: 'datetime')]
33
    private DateTimeImmutable $created_at;
34
35
    #[Column(type: 'datetime')]
36
    private DateTimeImmutable $updated_at;
37
38
    #[BelongsTo(target: User::class, nullable: false)]
39
    private ?User $user = null;
40
    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...
41
42
    public function __construct()
43
    {
44
        $this->created_at = new DateTimeImmutable();
45
        $this->updated_at = new DateTimeImmutable();
46
        $this->resetSlug();
47
    }
48
49
    public function getId(): ?int
50
    {
51
        return $this->id;
52
    }
53
54
    public function getSlug(): ?string
55
    {
56
        return $this->slug;
57
    }
58
59
    public function resetSlug(): void
60
    {
61
        $this->slug = Random::string(128);
62
    }
63
64
    public function getTitle(): string
65
    {
66
        return $this->title;
67
    }
68
69
    public function setTitle(string $title): void
70
    {
71
        $this->title = $title;
72
    }
73
74
    public function getContent(): string
75
    {
76
        return $this->content;
77
    }
78
79
    public function setContent(string $content): void
80
    {
81
        $this->content = $content;
82
    }
83
84
    public function setStatus(PostStatus $status): void
85
    {
86
        $this->status = $status->getValue();
87
    }
88
89
    public function getCreatedAt(): DateTimeImmutable
90
    {
91
        return $this->created_at;
92
    }
93
94
    public function getUpdatedAt(): DateTimeImmutable
95
    {
96
        return $this->updated_at;
97
    }
98
99
    public function setUser(User $user): void
100
    {
101
        $this->user = $user;
102
    }
103
104
    public function getUser(): ?User
105
    {
106
        return $this->user;
107
    }
108
}
109