Fix null params

This commit is contained in:
Pavlico 2021-09-15 12:11:35 +02:00 committed by David Garcia
parent 330ab10505
commit 84ffd0ff18

View File

@ -58,15 +58,16 @@ class MailingList extends HttpApi
* Creates a new mailing list on the current domain.
*
* @param string $address Address for the new mailing list
* @param string $name Name for the new mailing list (optional)
* @param string $description Description for the new mailing list (optional)
* @param string|null $name Name for the new mailing list (optional)
* @param string|null $description Description for the new mailing list (optional)
* @param string $accessLevel List access level, one of: readonly (default), members, everyone
*
* @param string $replyPreference
*
* @return CreateResponse
*
* @throws \Exception
*/
public function create(string $address, string $name = null, string $description = null, string $accessLevel = 'readonly', string $replyPreference = 'list')
public function create(string $address, ?string $name = null, ?string $description = null, string $accessLevel = 'readonly', string $replyPreference = 'list')
{
Assert::stringNotEmpty($address);
Assert::nullOrStringNotEmpty($name);
@ -76,11 +77,11 @@ class MailingList extends HttpApi
$params = [
'address' => $address,
'name' => $name,
'description' => $description,
'access_level' => $accessLevel,
'reply_preference' => $replyPreference,
];
$description ? $params['description'] = $description : false;
$name ? $params['name'] = $name : false;
$response = $this->httpPost('/v3/lists', $params);