Completed
Push — master ( eaa10a...12d04d )
by Albert
03:25
created

Post::setPublishedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Albert221\Blog\Entity;
4
5
use DateTime;
6
7
/**
8
 * @Entity(repositoryClass="\Albert221\Blog\Repository\DatabasePostRepository") @Table(name="posts")
9
 */
10
class Post
11
{
12
    /**
13
     * @var int Id
14
     * @Id @Column(type="integer") @GeneratedValue
15
     */
16
    protected $id;
17
18
    /**
19
     * @var string Title
20
     * @Column(type="string")
21
     */
22
    protected $title;
23
24
    /**
25
     * @var string Slug
26
     * @Column(type="string", unique=true)
27
     */
28
    protected $slug;
29
30
    /**
31
     * @var string Content
32
     * @Column(type="text")
33
     */
34
    protected $content;
35
36
    /**
37
     * @var DateTime Published at
38
     * @Column(type="datetime")
39
     */
40
    protected $published_at;
41
42
    /**
43
     * @var Category Category
44
     * @ManyToOne(targetEntity="Category", inversedBy="posts")
45
     */
46
    protected $category;
47
48
    public function getId()
49
    {
50
        return $this->id;
51
    }
52
53
    public function getTitle()
54
    {
55
        return $this->title;
56
    }
57
58
    public function setTitle($title)
59
    {
60
        $this->title = $title;
61
    }
62
63
    public function getSlug()
64
    {
65
        return $this->slug;
66
    }
67
68
    public function setSlug($slug)
69
    {
70
        $this->slug = $slug;
71
    }
72
73
    public function getContent()
74
    {
75
        return $this->content;
76
    }
77
78
    public function getShortContent()
79
    {
80
        return mb_substr($this->content, 0, mb_strpos($this->content, '<!--more-->'));
81
    }
82
83
    public function setContent($content)
84
    {
85
        $this->content = $content;
86
    }
87
88
    public function getPublishedAt()
89
    {
90
        return $this->published_at;
91
    }
92
93
    public function setPublishedAt(DateTime $published_at)
94
    {
95
        $this->published_at = $published_at;
96
    }
97
98
    public function setCategory($category)
99
    {
100
        $this->category = $category;
101
    }
102
103
    public function getCategory()
104
    {
105
        return $this->category;
106
    }
107
}
108