Subscription::getConfirmationCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Entities;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
10
/**
11
 * @since 2.0
12
 *
13
 * @ORM\Table( name="subscription" )
14
 * @ORM\Entity
15
 */
16
class Subscription {
17
18
	/**
19
	 * @var string
20
	 *
21
	 * @ORM\Column(name="full_name", type="string", length=250, options={"default":""}, nullable=false)
22
	 */
23
	private $fullName = '';
24
25
	/**
26
	 * @var string
27
	 *
28
	 * @ORM\Column(name="email", type="string", length=250, options={"default":""}, nullable=false)
29
	 */
30
	private $email = '';
31
32
	/**
33
	 * @var \DateTime|null
34
	 *
35
	 * @ORM\Column(name="export", type="datetime", nullable=true)
36
	 */
37
	private $export;
38
39
	/**
40
	 * @var \DateTime|null
41
	 *
42
	 * @ORM\Column(name="backup", type="datetime", nullable=true)
43
	 */
44
	private $backup;
45
46
	/**
47
	 * @var integer
48
	 *
49
	 * @ORM\Column(name="status", type="smallint", options={"default":0}, nullable=true)
50
	 */
51
	private $status = 0;
52
53
	/**
54
	 * @var string
55
	 *
56
	 * @ORM\Column(name="confirmationCode", type="string", length=32, nullable=true)
57
	 */
58
	private $confirmationCode;
59
60
	/**
61
	 * @var integer
62
	 *
63
	 * @ORM\Column(name="id", type="integer")
64
	 * @ORM\Id
65
	 * @ORM\GeneratedValue(strategy="IDENTITY")
66
	 */
67
	private $id;
68
69
	/**
70
	 * @ORM\ManyToOne(targetEntity="Address")
71
	 * @ORM\JoinColumn(name="address_id", referencedColumnName="id")
72
	 */
73
	private $address;
74
75
	/**
76
	 * @var string
77
	 *
78
	 * @ORM\Column(name="tracking", type="string", length=50, nullable=true)
79
	 */
80
	private $tracking;
81
82
	/**
83
	 * @var string
84
	 *
85
	 * @ORM\Column(name="source", type="string", length=50, nullable=true)
86
	 */
87
	private $source;
88
89
	/**
90
	 * @var \DateTime
91
	 * @Gedmo\Timestampable(on="create")
92
	 * @ORM\Column(type="datetime")
93
	 */
94
	private $createdAt;
95
96
	private const STATUS_NEW = 0;
97
	private const STATUS_CONFIRMED = 1;
98
	private const STATUS_MODERATION = 2;
99
100
	public function setFullName( string $fullName ): self {
101
		$this->fullName = $fullName;
102
103
		return $this;
104
	}
105
106
	public function getFullName(): string {
107
		return $this->fullName;
108
	}
109
110
	public function setEmail( string $email ): self {
111
		$this->email = $email;
112
113
		return $this;
114
	}
115
116
	public function getEmail(): string {
117
		return $this->email;
118
	}
119
120
	public function setExport( \DateTime $export = null ): self {
121
		$this->export = $export;
122
123
		return $this;
124
	}
125
126
	/**
127
	 * @return \DateTime|null
128
	 */
129
	public function getExport() {
130
		return $this->export;
131
	}
132
133
	public function setBackup( \DateTime $backup = null ): self {
134
		$this->backup = $backup;
135
136
		return $this;
137
	}
138
139
	/**
140
	 * @return \DateTime|null
141
	 */
142
	public function getBackup() {
143
		return $this->backup;
144
	}
145
146
	/**
147
	 * Usage of this method is discouraged, it's only for initialization with Doctrine.
148
	 *
149
	 * @see Subscription::markAsConfirmed()
150
	 * @see Subscription::markForModeration()
151
	 * @param int $status
152
	 * @return Subscription
153
	 */
154
	public function setStatus( int $status ): self {
155
		$this->status = $status;
156
157
		return $this;
158
	}
159
160
	/**
161
	 * Usage of this method is discouraged. Try using something like @see isUnconfirmed
162
	 *
163
	 * @return int
164
	 */
165
	public function getStatus(): int {
166
		return $this->status;
167
	}
168
169
	public function setConfirmationCode( string $confirmationCode ): self {
170
		$this->confirmationCode = $confirmationCode;
171
172
		return $this;
173
	}
174
175
	public function getConfirmationCode(): string {
176
		return $this->confirmationCode;
177
	}
178
179
	public function getId(): int {
180
		return $this->id;
181
	}
182
183
	public function getAddress(): Address {
184
		return $this->address;
185
	}
186
187
	public function setAddress( Address $address ) {
188
		$this->address = $address;
189
	}
190
191
	public function getCreatedAt(): \DateTime {
192
		return $this->createdAt;
193
	}
194
195
	public function setCreatedAt( \DateTime $createdAt ): self {
196
		$this->createdAt = $createdAt;
197
		return $this;
198
	}
199
200
	public function getTracking(): string {
201
		return $this->tracking;
202
	}
203
204
	public function setTracking( string $tracking ) {
205
		$this->tracking = $tracking;
206
	}
207
208
	/**
209
	 * @since 3.0
210
	 */
211 1
	public function setSource( string $source ): self {
212 1
		$this->source = $source;
213
214 1
		return $this;
215
	}
216
217
	/**
218
	 * @since 3.0
219
	 */
220 1
	public function getSource(): string {
221 1
		return $this->source;
222
	}
223
224
	/**
225
	 * @since 3.0
226
	 */
227 1
	public function markAsConfirmed() {
228 1
		$this->status = self::STATUS_CONFIRMED;
229 1
	}
230
231
	/**
232
	 * @since 3.0
233
	 */
234 2
	public function markForModeration() {
235 2
		$this->status = self::STATUS_MODERATION;
236 2
	}
237
238 3
	public function isUnconfirmed(): bool {
239 3
		return $this->status !== self::STATUS_CONFIRMED;
240
	}
241
242
	/**
243
	 * @since 3.0
244
	 */
245 2
	public function needsModeration(): bool {
246 2
		return $this->status === self::STATUS_MODERATION;
247
	}
248
249
}
250