Passed
Pull Request — master (#49)
by
unknown
14:38
created

Tag::getLabel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Entity;
4
5
use Cycle\Annotated\Annotation\Column;
6
use Cycle\Annotated\Annotation\Entity;
7
use Cycle\Annotated\Annotation\Relation\ManyToMany;
8
use Cycle\Annotated\Annotation\Table;
9
use Cycle\Annotated\Annotation\Table\Index;
10
use Cycle\ORM\Relation\Pivoted\PivotedCollection;
11
use DateTimeImmutable;
12
use Doctrine\Common\Collections\ArrayCollection;
13
14
/**
15
 * @Entity(repository="App\Repository\TagRepository", mapper="App\Mapper\TagMapper")
16
 * @Table(
17
 *     indexes={
18
 *         @Index(columns={"label"}, unique=true)
19
 *     }
20
 * )
21
 */
22
class Tag
23
{
24
    /**
25
     * @Column(type="primary")
26
     * @var int
27
     */
28
    private $id;
29
30
    /**
31
     * @Column(type="string(255)")
32
     * @var string
33
     */
34
    private $label;
35
36
    /**
37
     * @Column(type="datetime")
38
     * @var DateTimeImmutable
39
     */
40
    private $createdAt;
41
42
    /**
43
     * @ManyToMany(target="App\Entity\Post", though="PostTag", fkAction="CASCADE", indexCreate=false)
44
     * @var PivotedCollection
45
     */
46
    private $posts;
47
48
    public function __construct()
49
    {
50
        $this->posts = new PivotedCollection();
51
    }
52
53
    public function getId(): ?string
54
    {
55
        return $this->id;
56
    }
57
58
    public function getLabel(): string
59
    {
60
        return $this->label;
61
    }
62
63
    public function setLabel(string $label): void
64
    {
65
        $this->label = $label;
66
    }
67
68
    public function getCreatedAt(): DateTimeImmutable
69
    {
70
        return $this->createdAt;
71
    }
72
73
    /**
74
     * @return ArrayCollection|Post[]
75
     */
76
    public function getPosts(): ArrayCollection
77
    {
78
        return $this->posts;
79
    }
80
81
    public function addPost(Post $post): void
82
    {
83
        $this->posts->add($post);
84
    }
85
}
86