Test Setup Failed
Push — master ( 72a408...3f5e9b )
by Alexey
02:46
created

PostTag::setTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Table(name="posts_tags", schema="posts")
9
 * @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostTagRepository")
10
 */
11
class PostTag
12
{
13
    /**
14
     * @var int
15
     *
16
     * @ORM\Column(name="id", type="integer")
17
     * @ORM\Id
18
     * @ORM\GeneratedValue(strategy="AUTO")
19
     */
20
    private $id;
21
22
    /**
23
     * @var Post
24
     *
25
     * @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post", inversedBy="postTags")
26
     * @ORM\JoinColumn(name="post_id", onDelete="CASCADE")
27
     */
28
    private $post;
29
30
    /**
31
     * @var Tag
32
     *
33
     * @todo fix SET NULL
34
     *
35
     * @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Tag", fetch="EAGER")
36
     * @ORM\JoinColumn(name="tag_id", onDelete="SET NULL")
37
     */
38
    private $tag;
39
40
    /**
41
     * @var string
42
     *
43
     * @ORM\Column(name="text", type="text")
44
     */
45
    private $text;
46
47
48
    public function __construct(Tag $tag)
49
    {
50
        $this->tag = $tag;
51
    }
52
53
    public function getId(): int
54
    {
55
        return $this->id;
56
    }
57
58
    public function setText(string $text): self
59
    {
60
        $this->text = $text;
61
62
        return $this;
63
    }
64
65
    public function getText(): string
66
    {
67
        return $this->text;
68
    }
69
70
    public function getOriginalTagText(): string
71
    {
72
        return $this->tag ? $this->tag->getText() : '';
73
    }
74
75
    /**
76
     * Set post
77
     *
78
     * @todo move to constructor
79
     *
80
     * @param Post $post
81
     * @return PostTag
82
     */
83
    public function setPost(Post $post = null): self
84
    {
85
        $this->post = $post;
86
87
        return $this;
88
    }
89
90
    public function getPost(): Post
91
    {
92
        return $this->post;
93
    }
94
95
    public function getTag(): Tag
96
    {
97
        return $this->tag;
98
    }
99
}
100