Passed
Push — 1.11.x ( bce6cd...c146d9 )
by Angel Fernando Quiroz
12:25
created

src/Chamilo/ThemeBundle/Model/MessageModel.php (1 issue)

1
<?php
2
/**
3
 * MessageModel.php
4
 * avanzu-admin
5
 * Date: 23.02.14.
6
 */
7
8
namespace Chamilo\ThemeBundle\Model;
9
10
/**
11
 * Simple implementation of the MessageInterface.
12
 */
13
class MessageModel implements MessageInterface
14
{
15
    /**
16
     * Holds the sender.
17
     *
18
     * @var UserInterface
19
     */
20
    protected $from;
21
22
    /**
23
     * holds the Recipient.
24
     *
25
     * @var UserInterface
26
     */
27
    protected $to;
28
29
    /**
30
     * holds the date sent.
31
     *
32
     * @var \DateTime
33
     */
34
    protected $sentAt;
35
36
    /**
37
     * holds the subject.
38
     *
39
     * @var string
40
     */
41
    protected $subject;
42
43
    /**
44
     * Creates a new MessageModel object with the given values.
45
     *
46
     * SentAt will be set to the current DateTime when null is given.
47
     *
48
     * @param UserInterface $from
49
     * @param string        $subject
50
     * @param null          $sentAt
51
     * @param UserInterface $to
52
     */
53
    public function __construct(UserInterface $from = null, $subject = '', $sentAt = null, UserInterface $to = null)
54
    {
55
        $this->to = $to;
56
        $this->subject = $subject;
57
        $this->sentAt = $sentAt ?: new \DateTime();
0 ignored issues
show
$sentAt is of type null, thus it always evaluated to false.
Loading history...
58
        $this->from = $from;
59
    }
60
61
    /**
62
     * Set the sender.
63
     *
64
     * @param \Chamilo\ThemeBundle\Model\UserInterface $from
65
     *
66
     * @return $this
67
     */
68
    public function setFrom(UserInterface $from)
69
    {
70
        $this->from = $from;
71
72
        return $this;
73
    }
74
75
    /**
76
     * Get the Sender.
77
     *
78
     * @return \Chamilo\ThemeBundle\Model\UserInterface
79
     */
80
    public function getFrom()
81
    {
82
        return $this->from;
83
    }
84
85
    /**
86
     * Set the date sent.
87
     *
88
     * @return $this
89
     */
90
    public function setSentAt(\DateTime $sentAt)
91
    {
92
        $this->sentAt = $sentAt;
93
94
        return $this;
95
    }
96
97
    /**
98
     * Get the date sent.
99
     *
100
     * @return \DateTime
101
     */
102
    public function getSentAt()
103
    {
104
        return $this->sentAt;
105
    }
106
107
    /**
108
     * Set the subject.
109
     *
110
     * @param string $subject
111
     *
112
     * @return $this
113
     */
114
    public function setSubject($subject)
115
    {
116
        $this->subject = $subject;
117
118
        return $this;
119
    }
120
121
    /**
122
     * Get the subject.
123
     *
124
     * @return string
125
     */
126
    public function getSubject()
127
    {
128
        return $this->subject;
129
    }
130
131
    /**
132
     * Set the recipient.
133
     *
134
     * @param \Chamilo\ThemeBundle\Model\UserInterface $to
135
     *
136
     * @return $this
137
     */
138
    public function setTo(UserInterface $to)
139
    {
140
        $this->to = $to;
141
142
        return $this;
143
    }
144
145
    /**
146
     * Get the recipient.
147
     *
148
     * @return \Chamilo\ThemeBundle\Model\UserInterface
149
     */
150
    public function getTo()
151
    {
152
        return $this->to;
153
    }
154
155
    /**
156
     * Get the identifier.
157
     *
158
     * @return string
159
     */
160
    public function getIdentifier()
161
    {
162
        return $this->getSubject();
163
    }
164
}
165