Article::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Documents;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
7
/**
8
 * @Document(indexed=true)
9
 */
10
class Article
11
{
12
    /** @Id(type="string") */
13
    protected $id;
14
    /** @Field(type="string") */
15
    protected $title;
16
    /** @Field(type="string", indexed=true) */
17
    protected $slug;
18
    /** @Field(type="string") */
19
    protected $body;
20
    /** @Field(type="datetime") */
21
    protected $created;
22
    /** @EmbedMany(targetDocument="Documents\Tag") */
23
    protected $tags;
24
25
    public function __construct()
26
    {
27
        $this->tags = new ArrayCollection();
28
        $this->created = new \DateTime("now");
29
    }
30
31
    public function getId()
32
    {
33
        return $this->id;
34
    }
35
36
    public function getTitle()
37
    {
38
        return $this->title;
39
    }
40
41
    public function setTitle($title)
42
    {
43
        $this->title = $title;
44
    }
45
46
    public function getBody()
47
    {
48
        return $this->body;
49
    }
50
51
    public function setBody($body)
52
    {
53
        $this->body = $body;
54
    }
55
56
    public function getCreated()
57
    {
58
        return $this->created;
59
    }
60
61
    public function getTags()
62
    {
63
        return $this->tags;
64
    }
65
66
    public function addTag($tag)
67
    {
68
        $this->tags[] = new Tag($tag);
69
    }
70
}