|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* Copyright (C) 2013 Mailgun |
|
7
|
|
|
* |
|
8
|
|
|
* This software may be modified and distributed under the terms |
|
9
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Mailgun\Model\EmailValidation; |
|
13
|
|
|
|
|
14
|
|
|
use Mailgun\Model\ApiResponse; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author David Garcia <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
final class ValidateResponse implements ApiResponse |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var string|null |
|
23
|
|
|
*/ |
|
24
|
|
|
private $address; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string|null |
|
28
|
|
|
*/ |
|
29
|
|
|
private $didYouMean; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var bool |
|
33
|
|
|
*/ |
|
34
|
|
|
private $isDisposableAddress; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var bool |
|
38
|
|
|
*/ |
|
39
|
|
|
private $isRoleAddress; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var bool |
|
43
|
|
|
*/ |
|
44
|
|
|
private $isValid; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var bool |
|
48
|
|
|
*/ |
|
49
|
|
|
private $mailboxVerification; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Parts |
|
53
|
|
|
*/ |
|
54
|
|
|
private $parts; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var string|null |
|
58
|
|
|
*/ |
|
59
|
|
|
private $reason; |
|
60
|
|
|
|
|
61
|
3 |
|
private function __construct() |
|
62
|
|
|
{ |
|
63
|
3 |
|
} |
|
64
|
|
|
|
|
65
|
3 |
|
public static function create(array $data): self |
|
66
|
|
|
{ |
|
67
|
3 |
|
$model = new self(); |
|
68
|
3 |
|
$model->address = $data['address'] ?? null; |
|
69
|
3 |
|
$model->didYouMean = $data['did_you_mean'] ?? null; |
|
70
|
3 |
|
$model->isDisposableAddress = $data['is_disposable_address'] ?? false; |
|
71
|
3 |
|
$model->isRoleAddress = $data['is_role_address'] ?? false; |
|
72
|
3 |
|
$model->isValid = $data['is_valid'] ?? false; |
|
73
|
3 |
|
$model->mailboxVerification = isset($data['mailbox_verification']) ? 'true' === $data['mailbox_verification'] : false; |
|
74
|
3 |
|
$model->parts = Parts::create($data['parts'] ?? []); |
|
75
|
3 |
|
$model->reason = $data['reason'] ?? null; |
|
76
|
|
|
|
|
77
|
3 |
|
return $model; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
1 |
|
public function getAddress(): ?string |
|
81
|
|
|
{ |
|
82
|
1 |
|
return $this->address; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
1 |
|
public function getDidYouMean(): ?string |
|
86
|
|
|
{ |
|
87
|
1 |
|
return $this->didYouMean; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
1 |
|
public function isDisposableAddress(): bool |
|
91
|
|
|
{ |
|
92
|
1 |
|
return $this->isDisposableAddress; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
1 |
|
public function isRoleAddress(): bool |
|
96
|
|
|
{ |
|
97
|
1 |
|
return $this->isRoleAddress; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
1 |
|
public function isValid(): bool |
|
101
|
|
|
{ |
|
102
|
1 |
|
return $this->isValid; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
3 |
|
public function isMailboxVerification(): bool |
|
106
|
|
|
{ |
|
107
|
3 |
|
return $this->mailboxVerification; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
1 |
|
public function getParts(): Parts |
|
111
|
|
|
{ |
|
112
|
1 |
|
return $this->parts; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
1 |
|
public function getReason(): ?string |
|
116
|
|
|
{ |
|
117
|
1 |
|
return $this->reason; |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|