Completed
Push — master ( cc14f9...f9bab8 )
by Michael
02:32
created

Invitation::setEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace AppBundle\Entity;
3
4
use Doctrine\ORM\Mapping as ORM;
5
6
/**
7
 * @ORM\Entity
8
 * @ORM\Table(name="fos_invites")
9
 */
10
class Invitation
11
{
12
    /**
13
     * @ORM\Id
14
     * @ORM\Column(type="string", length=6)
15
     */
16
    protected $code;
17
18
    /**
19
     * @ORM\Column(type="string", length=256)
20
     */
21
    protected $email;
22
23
    /**
24
     * When sending invitation be sure to set this value to `true`
25
     *
26
     * It can prevent invitations from being sent twice
27
     *
28
     * @ORM\Column(type="boolean")
29
     */
30
    protected $sent = false;
31
32
    public function __construct()
33
    {
34
        // generate identifier only once, here a 6 characters length code
35
        $this->code = substr(md5(uniqid(rand(), true)), 0, 6);
36
    }
37
38
    public function getCode()
39
    {
40
        return $this->code;
41
    }
42
43
    public function getEmail()
44
    {
45
        return $this->email;
46
    }
47
48
    public function setEmail($email)
49
    {
50
        $this->email = $email;
51
    }
52
53
    public function isSent()
54
    {
55
        return $this->sent;
56
    }
57
58
    public function send()
59
    {
60
        $this->sent = true;
61
    }
62
}
63