1 | <?php |
||
31 | class Domain extends HttpApi |
||
32 | { |
||
33 | /** |
||
34 | * Returns a list of domains on the account. |
||
35 | * |
||
36 | * @param int $limit |
||
37 | * @param int $skip |
||
38 | * |
||
39 | * @return IndexResponse |
||
40 | */ |
||
41 | 1 | public function index(int $limit = 100, int $skip = 0) |
|
52 | |||
53 | /** |
||
54 | * Returns a single domain. |
||
55 | * |
||
56 | * @param string $domain name of the domain |
||
57 | * |
||
58 | * @return ShowResponse|array|ResponseInterface |
||
59 | */ |
||
60 | public function show(string $domain) |
||
68 | |||
69 | /** |
||
70 | * Creates a new domain for the account. |
||
71 | * See below for spam filtering parameter information. |
||
72 | * {@link https://documentation.mailgun.com/user_manual.html#um-spam-filter}. |
||
73 | * |
||
74 | * @see https://documentation.mailgun.com/en/latest/api-domains.html#domains |
||
75 | * |
||
76 | * @param string $domain name of the domain |
||
77 | * @param string $smtpPass password for SMTP authentication |
||
78 | * @param string $spamAction `disable` or `tag` - inbound spam filtering |
||
79 | * @param bool $wildcard domain will accept email for subdomains |
||
80 | * |
||
81 | * @return CreateResponse|array|ResponseInterface |
||
82 | */ |
||
83 | public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null) |
||
103 | |||
104 | /** |
||
105 | * Removes a domain from the account. |
||
106 | * WARNING: This action is irreversible! Be cautious! |
||
107 | * |
||
108 | * @param string $domain name of the domain |
||
109 | * |
||
110 | * @return DeleteResponse|array|ResponseInterface |
||
111 | */ |
||
112 | public function delete(string $domain) |
||
120 | |||
121 | /** |
||
122 | * Returns a list of SMTP credentials for the specified domain. |
||
123 | * |
||
124 | * @param string $domain name of the domain |
||
125 | * @param int $limit Number of credentials to return |
||
126 | * @param int $skip Number of credentials to omit from the list |
||
127 | * |
||
128 | * @return CredentialResponse |
||
129 | */ |
||
130 | public function credentials(string $domain, int $limit = 100, int $skip = 0) |
||
142 | |||
143 | /** |
||
144 | * Create a new SMTP credential pair for the specified domain. |
||
145 | * |
||
146 | * @param string $domain name of the domain |
||
147 | * @param string $login SMTP Username |
||
148 | * @param string $password SMTP Password. Length min 5, max 32. |
||
149 | * |
||
150 | * @return CreateCredentialResponse|array|ResponseInterface |
||
151 | */ |
||
152 | public function createCredential(string $domain, string $login, string $password) |
||
168 | |||
169 | /** |
||
170 | * Update a set of SMTP credentials for the specified domain. |
||
171 | * |
||
172 | * @param string $domain name of the domain |
||
173 | * @param string $login SMTP Username |
||
174 | * @param string $pass New SMTP Password. Length min 5, max 32. |
||
175 | * |
||
176 | * @return UpdateCredentialResponse|array|ResponseInterface |
||
177 | */ |
||
178 | public function updateCredential(string $domain, string $login, string $pass) |
||
193 | |||
194 | /** |
||
195 | * Remove a set of SMTP credentials from the specified domain. |
||
196 | * |
||
197 | * @param string $domain name of the domain |
||
198 | * @param string $login SMTP Username |
||
199 | * |
||
200 | * @return DeleteCredentialResponse|array|ResponseInterface |
||
201 | */ |
||
202 | public function deleteCredential(string $domain, string $login) |
||
217 | |||
218 | /** |
||
219 | * Returns delivery connection settings for the specified domain. |
||
220 | * |
||
221 | * @param string $domain name of the domain |
||
222 | * |
||
223 | * @return ConnectionResponse|ResponseInterface |
||
224 | */ |
||
225 | public function connection(string $domain) |
||
233 | |||
234 | /** |
||
235 | * Updates the specified delivery connection settings for the specified domain. |
||
236 | * If a parameter is passed in as null, it will not be updated. |
||
237 | * |
||
238 | * @param string $domain name of the domain |
||
239 | * @param bool|null $requireTLS enforces that messages are sent only over a TLS connection |
||
240 | * @param bool|null $noVerify disables TLS certificate and hostname verification |
||
241 | * |
||
242 | * @return UpdateConnectionResponse|array|ResponseInterface |
||
243 | */ |
||
244 | public function updateConnection(string $domain, ?bool $requireTLS, ?bool $noVerify) |
||
261 | |||
262 | /** |
||
263 | * Returns a single domain. |
||
264 | * |
||
265 | * @param string $domain name of the domain |
||
266 | * |
||
267 | * @return VerifyResponse|array|ResponseInterface |
||
268 | */ |
||
269 | public function verify(string $domain) |
||
277 | } |
||
278 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.