Completed
Push — master ( 749edd...721fe7 )
by Park Jong-Hun
10:14
created

Comment::getCreatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Entity;
4
5
use \DateTime;
6
use App\Entity\User;
7
8
/**
9
 * @Entity
10
 * @Table(name="comments")
11
 */
12
class Comment
13
{
14
    /**
15
     * @Id
16
     * @Column(type="integer")
17
     * @GeneratedValue
18
     */
19
    protected $id;
20
21
    /**
22
     * @var Post
23
     * @ManyToOne(targetEntity="Post")
24
     * @JoinColumn(name="post", referencedColumnName="id")
25
     */
26
    protected $post;
27
28
    /**
29
     * @Column(type="text", length=65535)
30
     */
31
    protected $content;
32
33
    /**
34
     * @var User
35
     * @ManyToOne(targetEntity="User")
36
     */
37
    protected $user;
38
39
    /**
40
     * @Column(type="string", length=32)
41
     */
42
    protected $author;
43
44
    /**
45
     * @Column(type="string", length=128)
46
     */
47
    protected $password;
48
49
    /**
50
     * @var DateTime
51
     * @Column(type="datetime")
52
     */
53
    protected $created_at;
54
55
    /**
56
     * @var DateTime
57
     * @Column(type="datetime")
58
     */
59
    protected $updated_at;
60
61
62
    public function __construct()
63
    {
64
        $this->created_at = new DateTime();
65
        $this->updated_at = $this->created_at;
66
    }
67
68
    public function getId()
69
    {
70
        return $this->id;
71
    }
72
73
    public function setPost($post)
74
    {
75
        $this->post = $post;
76
    }
77
78
    public function getPost()
79
    {
80
        return $this->post;
81
    }
82
83
    public function setContent($content)
84
    {
85
        $this->content = $content;
86
    }
87
88
    public function getContent()
89
    {
90
        return $this->content;
91
    }
92
93
    public function setUser(User $user)
94
    {
95
        $this->user = $user;
96
    }
97
98
    public function getUser()
99
    {
100
        return $this->user;
101
    }
102
103
    public function setAuthor($author)
104
    {
105
        $this->author = $author;
106
    }
107
108
    public function getAuthor()
109
    {
110
        if ($this->user) {
111
            return $this->user->getNickname();
112
        }
113
        return $this->author;
114
    }
115
116
    public function setPassword($password)
117
    {
118
        $this->password = $password;
119
    }
120
121
    public function getPassword()
122
    {
123
        if ($this->user) {
124
            return $this->user->getPassword();
125
        }
126
        return $this->password;
127
    }
128
129
    public function getCreatedAt()
130
    {
131
        return $this->created_at;
132
    }
133
134
    public function setUpdatedAt(DateTime $datetime)
135
    {
136
        $this->updated_at = $datetime;
137
    }
138
}
139