1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (C) 2013 Mailgun |
5
|
|
|
* |
6
|
|
|
* This software may be modified and distributed under the terms |
7
|
|
|
* of the MIT license. See the LICENSE file for details. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Mailgun\Model\MailingList; |
11
|
|
|
|
12
|
|
|
use Mailgun\Model\ApiResponse; |
13
|
|
|
|
14
|
|
|
final class MailingList implements ApiResponse |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private $name; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
private $address; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $accessLevel; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $description; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var int |
38
|
|
|
*/ |
39
|
|
|
private $membersCount; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var \DateTime |
43
|
|
|
*/ |
44
|
|
|
private $createdAt; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param array $data |
48
|
|
|
* |
49
|
|
|
* @return self |
50
|
|
|
*/ |
51
|
3 |
View Code Duplication |
public static function create(array $data) |
|
|
|
|
52
|
|
|
{ |
53
|
3 |
|
return new self( |
54
|
3 |
|
isset($data['name']) ? $data['name'] : null, |
55
|
3 |
|
isset($data['address']) ? $data['address'] : null, |
56
|
3 |
|
isset($data['access_level']) ? $data['access_level'] : null, |
57
|
3 |
|
isset($data['description']) ? $data['description'] : null, |
58
|
3 |
|
isset($data['members_count']) ? $data['members_count'] : null, |
59
|
3 |
|
isset($data['created_at']) ? new \DateTime($data['created_at']) : null |
|
|
|
|
60
|
3 |
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* MailingList constructor. |
65
|
|
|
* |
66
|
|
|
* @param string $name |
67
|
|
|
* @param string $address |
68
|
|
|
* @param string $accessLevel |
69
|
|
|
* @param string $description |
70
|
|
|
* @param int $membersCount |
71
|
|
|
* @param \DateTime $createdAt |
72
|
|
|
*/ |
73
|
3 |
|
private function __construct($name, $address, $accessLevel, $description, $membersCount, \DateTime $createdAt) |
74
|
|
|
{ |
75
|
3 |
|
$this->name = $name; |
76
|
3 |
|
$this->address = $address; |
77
|
3 |
|
$this->accessLevel = $accessLevel; |
78
|
3 |
|
$this->description = $description; |
79
|
3 |
|
$this->membersCount = $membersCount; |
80
|
3 |
|
$this->createdAt = $createdAt; |
81
|
3 |
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function getName() |
87
|
|
|
{ |
88
|
|
|
return $this->name; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getAddress() |
95
|
|
|
{ |
96
|
|
|
return $this->address; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
1 |
|
public function getAccessLevel() |
103
|
|
|
{ |
104
|
1 |
|
return $this->accessLevel; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
|
|
public function getDescription() |
111
|
|
|
{ |
112
|
|
|
return $this->description; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return int |
117
|
|
|
*/ |
118
|
2 |
|
public function getMembersCount() |
119
|
|
|
{ |
120
|
2 |
|
return $this->membersCount; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return \DateTime |
125
|
|
|
*/ |
126
|
|
|
public function getCreatedAt() |
127
|
|
|
{ |
128
|
|
|
return $this->createdAt; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.