-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I've discovered that empty arrays are not supported by this library for array values. Instead, an explicit null value is expected to represent an array with no elements. Otherwise, a get_class(): Argument #1 ($object) must be of type object, array given exception will be thrown.
From my perspective, this behavior feels somewhat unintuitive, as it requires rechecking and explicitly setting values to null when mapping data from internal objects to Apideck objects, instead of simply accepting empty arrays.
For instance, the following code:
$lead->emails = $my_lead->emails->map(fn ($email) => new Email(email: $email))->toArray();needs to be rewritten as:
$lead->emails = $my_lead->emails->map(fn ($email) => new Email(email: $email))->toArray();
if (count($lead->emails) == 0) $lead->emails = null;I would suggest and prefer that the library supports empty arrays alongside null values for array elements.
Metadata
Metadata
Assignees
Labels
No labels