1 | <?php |
||
33 | class Domain extends HttpApi |
||
34 | { |
||
35 | /** |
||
36 | * Returns a list of domains on the account. |
||
37 | * |
||
38 | * @return IndexResponse |
||
39 | */ |
||
40 | 1 | public function index(int $limit = 100, int $skip = 0) |
|
53 | |||
54 | /** |
||
55 | * Returns a single domain. |
||
56 | * |
||
57 | * @param string $domain name of the domain |
||
58 | * |
||
59 | * @return ShowResponse|array|ResponseInterface |
||
60 | */ |
||
61 | 1 | public function show(string $domain) |
|
69 | |||
70 | /** |
||
71 | * Creates a new domain for the account. |
||
72 | * See below for spam filtering parameter information. |
||
73 | * {@link https://documentation.mailgun.com/user_manual.html#um-spam-filter}. |
||
74 | * |
||
75 | * @see https://documentation.mailgun.com/en/latest/api-domains.html#domains |
||
76 | * |
||
77 | * @param string $domain name of the domain |
||
78 | * @param string $smtpPass password for SMTP authentication |
||
79 | * @param string $spamAction `disable` or `tag` - inbound spam filtering |
||
80 | * @param bool $wildcard domain will accept email for subdomains |
||
81 | * @param bool $forceDkimAuthority force DKIM authority |
||
82 | * @param string[] $ips an array of ips to be assigned to the domain |
||
83 | * |
||
84 | * @return CreateResponse|array|ResponseInterface |
||
85 | */ |
||
86 | 7 | public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null, ?array $ips = null) |
|
128 | |||
129 | /** |
||
130 | * Removes a domain from the account. |
||
131 | * WARNING: This action is irreversible! Be cautious! |
||
132 | * |
||
133 | * @param string $domain name of the domain |
||
134 | * |
||
135 | * @return DeleteResponse|array|ResponseInterface |
||
136 | */ |
||
137 | 1 | public function delete(string $domain) |
|
145 | |||
146 | /** |
||
147 | * Returns a list of SMTP credentials for the specified domain. |
||
148 | * |
||
149 | * @param string $domain name of the domain |
||
150 | * @param int $limit Number of credentials to return |
||
151 | * @param int $skip Number of credentials to omit from the list |
||
152 | * |
||
153 | * @return CredentialResponse |
||
154 | */ |
||
155 | public function credentials(string $domain, int $limit = 100, int $skip = 0) |
||
167 | |||
168 | /** |
||
169 | * Create a new SMTP credential pair for the specified domain. |
||
170 | * |
||
171 | * @param string $domain name of the domain |
||
172 | * @param string $login SMTP Username |
||
173 | * @param string $password SMTP Password. Length min 5, max 32. |
||
174 | * |
||
175 | * @return CreateCredentialResponse|array|ResponseInterface |
||
176 | */ |
||
177 | 1 | public function createCredential(string $domain, string $login, string $password) |
|
193 | |||
194 | /** |
||
195 | * Update a set of SMTP credentials for the specified domain. |
||
196 | * |
||
197 | * @param string $domain name of the domain |
||
198 | * @param string $login SMTP Username |
||
199 | * @param string $pass New SMTP Password. Length min 5, max 32. |
||
200 | * |
||
201 | * @return UpdateCredentialResponse|array|ResponseInterface |
||
202 | */ |
||
203 | 1 | public function updateCredential(string $domain, string $login, string $pass) |
|
218 | |||
219 | /** |
||
220 | * Remove a set of SMTP credentials from the specified domain. |
||
221 | * |
||
222 | * @param string $domain name of the domain |
||
223 | * @param string $login SMTP Username |
||
224 | * |
||
225 | * @return DeleteCredentialResponse|array|ResponseInterface |
||
226 | */ |
||
227 | 1 | public function deleteCredential(string $domain, string $login) |
|
242 | |||
243 | /** |
||
244 | * Returns delivery connection settings for the specified domain. |
||
245 | * |
||
246 | * @param string $domain name of the domain |
||
247 | * |
||
248 | * @return ConnectionResponse|ResponseInterface |
||
249 | */ |
||
250 | 1 | public function connection(string $domain) |
|
258 | |||
259 | /** |
||
260 | * Updates the specified delivery connection settings for the specified domain. |
||
261 | * If a parameter is passed in as null, it will not be updated. |
||
262 | * |
||
263 | * @param string $domain name of the domain |
||
264 | * @param bool|null $requireTLS enforces that messages are sent only over a TLS connection |
||
265 | * @param bool|null $noVerify disables TLS certificate and hostname verification |
||
266 | * |
||
267 | * @return UpdateConnectionResponse|array|ResponseInterface |
||
268 | */ |
||
269 | 1 | public function updateConnection(string $domain, ?bool $requireTLS, ?bool $noVerify) |
|
286 | |||
287 | /** |
||
288 | * Returns a single domain. |
||
289 | * |
||
290 | * @param string $domain name of the domain |
||
291 | * |
||
292 | * @return VerifyResponse|array|ResponseInterface |
||
293 | */ |
||
294 | 1 | public function verify(string $domain) |
|
302 | } |
||
303 |
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.