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

Post::getPassword()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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