Tag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
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\Tag\TagRepository;
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\ManyToMany;
0 ignored issues
show
Bug introduced by
The type Cycle\Annotated\Annotation\Relation\ManyToMany 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\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...
12
use Cycle\ORM\Collection\Pivoted\PivotedCollection;
0 ignored issues
show
Bug introduced by
The type Cycle\ORM\Collection\Pivoted\PivotedCollection 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\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...
14
use DateTimeImmutable;
15
16
#[Entity(repository: TagRepository::class)]
17
#[Index(columns: ['label'], unique: true)]
18
#[Behavior\CreatedAt(field: 'created_at', column: 'created_at')]
19
class Tag
20
{
21
    #[Column(type: 'primary')]
22
    private ?int $id = null;
23
24
    #[Column(type: 'string(191)')]
25
    private string $label;
26
27
    #[Column(type: 'datetime')]
28
    private DateTimeImmutable $created_at;
29
30
    /**
31
     * @var PivotedCollection<array-key, Post, PostTag>
32
     */
33
    #[ManyToMany(target: Post::class, though: PostTag::class, fkAction: 'CASCADE', indexCreate: false)]
34
    private PivotedCollection $posts;
35
36
    public function __construct(string $label)
37
    {
38
        $this->label = $label;
39
        $this->created_at = new DateTimeImmutable();
40
        $this->posts = new PivotedCollection();
41
    }
42
43
    public function getId(): ?int
44
    {
45
        return $this->id;
46
    }
47
48
    public function getLabel(): string
49
    {
50
        return $this->label;
51
    }
52
53
    public function setLabel(string $label): void
54
    {
55
        $this->label = $label;
56
    }
57
58
    public function getCreatedAt(): DateTimeImmutable
59
    {
60
        return $this->created_at;
61
    }
62
63
    /**
64
     * @return Post[]
65
     */
66
    public function getPosts(): array
67
    {
68
        return $this->posts->toArray();
69
    }
70
71
    public function addPost(Post $post): void
72
    {
73
        $this->posts->add($post);
74
    }
75
}
76