/
ResponseItem.php
76 lines (64 loc) · 1.42 KB
/
ResponseItem.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace MauticPlugin\MauticSendinblueBundle\Swiftmailer\Callback;
use MauticPlugin\MauticSendinblueBundle\Swiftmailer\Exception\ResponseItemException;
/**
* Class ResponseItem.
*/
class ResponseItem
{
/**
* @var string
*/
private $email;
/**
* @var string
*/
private $reason;
/**
* @var int
*/
private $dncReason;
/**
* ResponseItem constructor.
*
* @param array $item
*
* @throws ResponseItemException
*/
public function __construct(array $item)
{
if (!isset($item['email']) || (isset($item['email']) && empty($item['email']))) {
throw new ResponseItemException('Email must not be empty.');
}
$this->email = is_array($item['email']) ? reset($item['email']) : $item['email'];
$this->reason = isset($item['reason']) ? $item['reason'] : null;
$this->dncReason = CallbackEnum::convertEventToDncReason($item['event']);
}
/**
* Gets an email of the event.
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Gets a reason of the event.
*
* @return string
*/
public function getReason()
{
return $this->reason;
}
/**
* Gets DNC reason of the event.
*
* @return int
*/
public function getDncReason()
{
return $this->dncReason;
}
}