Skip to content

re: Refactoring "if" statements with lookup arrays in PHP/Laravel VIEW POST


That request data looks to be a handful to deal with and raises some questions about the design of the data:

  • Why phone number in top level?
  • Why phone number in billing_address?
  • Why phone number in shipping_address?
  • Why the duplication?

After we've accepted the fact the data is what it is, we still have at least one big issue to handle.

  • What if the data is not consistent? What if we find two different phone numbers in the data? Which one do we prioritize over another.

To me it seems there's not much room to move around the problem. We'll have to parse the data somehow and it's going to be messy.

The trade off looks to be around "explicit vs. dynamic" algorithm.

code of conduct - report abuse