Passed
Push — master ( ddbf8b...086098 )
by Robbie
11:17
created

Item::isConfirmed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Security\Confirmation;
4
5
/**
6
 * Confirmation item is a simple data object
7
 * incapsulating a single confirmation unit,
8
 * its unique identifier (token), its human
9
 * friendly name, description and the status
10
 * whether it has already been confirmed.
11
 */
12
class Item
13
{
14
    /**
15
     * A confirmation token which is
16
     * unique for every confirmation item
17
     *
18
     * @var string
19
     */
20
    private $token;
21
22
    /**
23
     * Human readable item name
24
     *
25
     * @var string
26
     */
27
    private $name;
28
29
    /**
30
     * Human readable description of the item
31
     *
32
     * @var string
33
     */
34
    private $description;
35
36
    /**
37
     * Whether the item has been confirmed or not
38
     *
39
     * @var bool
40
     */
41
    private $confirmed;
42
43
    /**
44
     * @param string $token unique token of this confirmation item
45
     * @param string $name Human readable name of the item
46
     * @param string $description Human readable description of the item
47
     */
48
    public function __construct($token, $name, $description)
49
    {
50
        $this->token = $token;
51
        $this->name = $name;
52
        $this->description = $description;
53
        $this->confirmed = false;
54
    }
55
56
    /**
57
     * Returns the token of the item
58
     *
59
     * @return string
60
     */
61
    public function getToken()
62
    {
63
        return $this->token;
64
    }
65
66
    /**
67
     * Returns the item name (human readable)
68
     *
69
     * @return string
70
     */
71
    public function getName()
72
    {
73
        return $this->name;
74
    }
75
76
    /**
77
     * Returns the human readable description of the item
78
     *
79
     * @return string
80
     */
81
    public function getDescription()
82
    {
83
        return $this->description;
84
    }
85
86
    /**
87
     * Returns whether the item has been confirmed
88
     *
89
     * @return bool
90
     */
91
    public function isConfirmed()
92
    {
93
        return $this->confirmed;
94
    }
95
96
    /**
97
     * Mark the item as confirmed
98
     */
99
    public function confirm()
100
    {
101
        $this->confirmed = true;
102
    }
103
}
104