Completed
Push — master ( 4338c7...e2596c )
by Gabriel
31s
created

Subscription::markForModeration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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