EventSaucePHP / ObjectHydrator

Object Hydration library to create Command and Query objects.
MIT License
318 stars 24 forks source link

Object keys with numbers do not format correctly by default #70

Closed shadowhand closed 4 months ago

shadowhand commented 4 months ago

The default key formatter uses the regex pattern /(.)(?=[A-Z])/u.

This regex pattern does not properly handle key names like procedureModifier1 which I would expect to formats to/from procedure_modifier_1. It currently translates formats to/from procedure_modifier1.

Changing the regex to /(.)(?=[A-Z0-9])/u corrects the formatting.

shadowhand commented 4 months ago

This is purely a matter of preference. In fact, using a custom formatter in a project created another bug where it was not expected to have the underscore before a number. 🤦🏼‍♂️