Completed
Pull Request — master (#246)
by Tobias
10:39
created

IndexResponse   A

Complexity

Total Complexity 30

Size/Duplication

Total Lines 203
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 30
lcom 1
cbo 0
dl 0
loc 203
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
D create() 0 27 8
A getBounceUrl() 0 6 2
A setBounce() 0 4 1
A getDeliverUrl() 0 6 2
A setDeliver() 0 4 1
A getDropUrl() 0 6 2
A setDrop() 0 4 1
A getSpamUrl() 0 6 2
A setSpam() 0 4 1
A getUnsubscribeUrl() 0 6 2
A setUnsubscribe() 0 4 1
A getClickUrl() 0 6 2
A setClick() 0 4 1
A getOpenUrl() 0 6 2
A setOpen() 0 4 1
1
<?php
2
3
namespace Mailgun\Resource\Api\Webhook;
4
5
use Mailgun\Resource\ApiResponse;
6
7
/**
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
class IndexResponse implements ApiResponse
11
{
12
    /**
13
     * @var array
14
     */
15
    private $bounce = [];
16
17
    /**
18
     * @var array
19
     */
20
    private $deliver = [];
21
22
    /**
23
     * @var array
24
     */
25
    private $drop = [];
26
27
    /**
28
     * @var array
29
     */
30
    private $spam = [];
31
32
    /**
33
     * @var array
34
     */
35
    private $unsubscribe = [];
36
37
    /**
38
     * @var array
39
     */
40
    private $click = [];
41
42
    /**
43
     * @var array
44
     */
45
    private $open = [];
46
47
    /**
48
     * Do not let this object be creted without the ::create.
49
     */
50
    private function __construct()
51
    {
52
    }
53
54
    /**
55
     * @param array $data
56
     *
57
     * @return IndexResponse
58
     */
59
    public static function create(array $data)
60
    {
61
        $self = new self();
62
        if (isset($data['bounce'])) {
63
            $self->setBounce($data['bounce']);
64
        }
65
        if (isset($data['deliver'])) {
66
            $self->setDeliver($data['deliver']);
67
        }
68
        if (isset($data['drop'])) {
69
            $self->setDrop($data['drop']);
70
        }
71
        if (isset($data['spam'])) {
72
            $self->setSpam($data['spam']);
73
        }
74
        if (isset($data['unsubscribe'])) {
75
            $self->setUnsubscribe($data['unsubscribe']);
76
        }
77
        if (isset($data['click'])) {
78
            $self->setClick($data['click']);
79
        }
80
        if (isset($data['open'])) {
81
            $self->setOpen($data['open']);
82
        }
83
84
        return $self;
85
    }
86
87
    /**
88
     * @return string|null
89
     */
90
    public function getBounceUrl()
91
    {
92
        if (isset($this->bounce['url'])) {
93
            return $this->bounce['url'];
94
        }
95
    }
96
97
    /**
98
     * @param array $bounce
99
     */
100
    private function setBounce($bounce)
101
    {
102
        $this->bounce = $bounce;
103
    }
104
105
    /**
106
     * @return string|null
107
     */
108
    public function getDeliverUrl()
109
    {
110
        if (isset($this->deliver['url'])) {
111
            return $this->deliver['url'];
112
        }
113
    }
114
115
    /**
116
     * @param array $deliver
117
     */
118
    private function setDeliver($deliver)
119
    {
120
        $this->deliver = $deliver;
121
    }
122
123
    /**
124
     * @return string|null
125
     */
126
    public function getDropUrl()
127
    {
128
        if (isset($this->drop['url'])) {
129
            return $this->drop['url'];
130
        }
131
    }
132
133
    /**
134
     * @param array $drop
135
     */
136
    private function setDrop($drop)
137
    {
138
        $this->drop = $drop;
139
    }
140
141
    /**
142
     * @return string|null
143
     */
144
    public function getSpamUrl()
145
    {
146
        if (isset($this->spam['url'])) {
147
            return $this->spam['url'];
148
        }
149
    }
150
151
    /**
152
     * @param array $spam
153
     */
154
    private function setSpam($spam)
155
    {
156
        $this->spam = $spam;
157
    }
158
159
    /**
160
     * @return string|null
161
     */
162
    public function getUnsubscribeUrl()
163
    {
164
        if (isset($this->unsubscribe['url'])) {
165
            return $this->unsubscribe['url'];
166
        }
167
    }
168
169
    /**
170
     * @param array $unsubscribe
171
     */
172
    private function setUnsubscribe($unsubscribe)
173
    {
174
        $this->unsubscribe = $unsubscribe;
175
    }
176
177
    /**
178
     * @return string|null
179
     */
180
    public function getClickUrl()
181
    {
182
        if (isset($this->click['url'])) {
183
            return $this->click['url'];
184
        }
185
    }
186
187
    /**
188
     * @param array $click
189
     */
190
    private function setClick($click)
191
    {
192
        $this->click = $click;
193
    }
194
195
    /**
196
     * @return string|null
197
     */
198
    public function getOpenUrl()
199
    {
200
        if (isset($this->open['url'])) {
201
            return $this->open['url'];
202
        }
203
    }
204
205
    /**
206
     * @param array $open
207
     */
208
    private function setOpen($open)
209
    {
210
        $this->open = $open;
211
    }
212
}
213