Passed
Push — issue#699 ( 0bf7c9...500e2d )
by Guilherme
04:01
created

SentEmail::setSender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
use Ramsey\Uuid\Uuid;
15
16
/**
17
 * SentEmail
18
 *
19
 * @ORM\Table(name="sent_email")
20
 * @ORM\Entity(repositoryClass="LoginCidadao\CoreBundle\Entity\SentEmailRepository")
21
 */
22
class SentEmail
23
{
24
    /**
25
     * @var integer
26
     *
27
     * @ORM\Column(name="id", type="integer")
28
     * @ORM\Id
29
     * @ORM\GeneratedValue(strategy="AUTO")
30
     */
31
    private $id;
32
33
    /**
34
     * @var \DateTime
35
     *
36
     * @ORM\Column(name="date", type="datetime")
37
     */
38
    private $date;
39
40
    /**
41
     * @var string
42
     *
43
     * @ORM\Column(name="receiver", type="string", length=255)
44
     */
45
    private $receiver;
46
47
    /**
48
     * @var string
49
     *
50
     * @ORM\Column(name="sender", type="string", length=255)
51
     */
52
    private $sender;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(name="subject", type="string", length=255)
58
     */
59
    private $subject;
60
61
    /**
62
     * @var string
63
     *
64
     * @ORM\Column(name="message", type="text")
65
     */
66
    private $message;
67
68
    /**
69
     * @var string
70
     *
71
     * @ORM\Column(name="type", type="string", length=255)
72
     */
73
    private $type;
74
75
    /**
76
     * @var string
77
     *
78
     * @ORM\Column(name="support_ticket", type="string", length=255, unique=true)
79
     */
80
    private $supportTicket;
81
82
    public function __construct()
83
    {
84
        $this->setDate(new \DateTime());
85
        try {
86
            $this->supportTicket = Uuid::uuid4();
0 ignored issues
show
Documentation Bug introduced by
It seems like Ramsey\Uuid\Uuid::uuid4() of type Ramsey\Uuid\UuidInterface is incompatible with the declared type string of property $supportTicket.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
87
        } catch (\Exception $e) {
88
            $this->supportTicket = bin2hex(random_bytes(4));
89
        }
90
    }
91
92
    /**
93
     * Get id
94
     *
95
     * @return integer
96
     */
97
    public function getId()
98
    {
99
        return $this->id;
100
    }
101
102
    /**
103
     * Set date
104
     *
105
     * @param \DateTime $date
106
     * @return SentEmail
107
     */
108
    public function setDate($date)
109
    {
110
        $this->date = $date;
111
112
        return $this;
113
    }
114
115
    /**
116
     * Get date
117
     *
118
     * @return \DateTime
119
     */
120
    public function getDate()
121
    {
122
        return $this->date;
123
    }
124
125
    /**
126
     * Set receiver
127
     *
128
     * @param string $receiver
129
     * @return SentEmail
130
     */
131
    public function setReceiver($receiver)
132
    {
133
        $this->receiver = $receiver;
134
135
        return $this;
136
    }
137
138
    /**
139
     * Get receiver
140
     *
141
     * @return string
142
     */
143
    public function getReceiver()
144
    {
145
        return $this->receiver;
146
    }
147
148
    /**
149
     * Set sender
150
     *
151
     * @param string $sender
152
     * @return SentEmail
153
     */
154
    public function setSender($sender)
155
    {
156
        $this->sender = $sender;
157
158
        return $this;
159
    }
160
161
    /**
162
     * Get sender
163
     *
164
     * @return string
165
     */
166
    public function getSender()
167
    {
168
        return $this->sender;
169
    }
170
171
    /**
172
     * Set subject
173
     *
174
     * @param string $subject
175
     * @return SentEmail
176
     */
177
    public function setSubject($subject)
178
    {
179
        $this->subject = $subject;
180
181
        return $this;
182
    }
183
184
    /**
185
     * Get subject
186
     *
187
     * @return string
188
     */
189
    public function getSubject()
190
    {
191
        return $this->subject;
192
    }
193
194
    /**
195
     * Set message
196
     *
197
     * @param string $message
198
     * @return SentEmail
199
     */
200
    public function setMessage($message)
201
    {
202
        $this->message = $message;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Get message
209
     *
210
     * @return string
211
     */
212
    public function getMessage()
213
    {
214
        return $this->message;
215
    }
216
217
    /**
218
     * Set type
219
     *
220
     * @param string $type
221
     * @return SentEmail
222
     */
223
    public function setType($type)
224
    {
225
        $this->type = $type;
226
227
        return $this;
228
    }
229
230
    /**
231
     * Get type
232
     *
233
     * @return string
234
     */
235
    public function getType()
236
    {
237
        return $this->type;
238
    }
239
240
    /**
241
     * @return string
242
     */
243
    public function getSupportTicket(): string
244
    {
245
        return $this->supportTicket;
246
    }
247
248
    public function getSwiftMail()
249
    {
250
        return (new \Swift_Message($this->getSubject()))
251
            ->setFrom($this->getSender())
252
            ->setTo($this->getReceiver())
253
            ->setBody($this->getMessage(), 'text/html');
254
    }
255
}
256