Closed kamil-klasicki closed 3 years ago
Ok so this 🐫 logic was already there and all your doing is making a special method and calling it somewhere we missed?
Yeah exactly, you can see that setAttributes method has the: $this->{lcfirst(strreplace('', '', ucwords(ltrim($key, '$'), '_')))} = $value; has the logic that converts the snake case into camelCase so the properties are set correctly.
We currently don't do it inside of json_Serialize, so when we do property_exists check, it will skip the ones that don't match (first_name/firstName, last_name/lastName, phone_number/phoneNumber)
The profileModel class has its properties listed using camelCase notation. As we are now doing a a property check between '$this' and $properties, the values that use snake_casing such as first_name or last_name will be missed out.
As the code uses camelCasing across the board, we should keep this consistent and so before checking if property exists, we should do a conversion to camelCase.
This already happens inside of setAttributes() method, so the PR simply pulls out that logic and puts it in its own function. We can then call it before '!property_exists' to make sure all values align.