Skip to content

Conversation

@kevinmeijer97
Copy link
Member

No description provided.

}
}

return $field['value'] ?? null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use a match?

$type = $field['type'] ?? null;

return match (true) {
    $type === 'array' && isset($field['values']) => $field['values'],
    $type === 'object' && isset($field['value']) => $field['value'],
    $type === 'object_array' && isset($field['values']) => $field['values'],
    $type === 'numeric'
        && isset($field['value'])
        && is_numeric($field['value']) => (float) $field['value'],
    default => $field['value'] ?? null,
};

return match ($type) {
'replicator_object_array' => new ReplicatorObjectArrayTransformer,
default => new DefaultFieldTransformer,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just has one condition, then i'd make it an if

*/
protected function extractFieldData($setFieldKey, $setFieldData): ?array
{
// Handle list array format: [['handle' => 'text', 'field' => [...]]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only comments in this function? 😜 I think they can be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants