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.
I've discovered that empty arrays are not supported by this library for array values. Instead, an explicit
nullvalue is expected to represent an array with no elements. Otherwise, aget_class(): Argument #1 ($object) must be of type object, array givenexception will be thrown.From my perspective, this behavior feels somewhat unintuitive, as it requires rechecking and explicitly setting values to
nullwhen mapping data from internal objects to Apideck objects, instead of simply accepting empty arrays.For instance, the following code:
needs to be rewritten as:
I would suggest and prefer that the library supports empty arrays alongside
nullvalues for array elements.