Factory Methods for Hydrating Objects from JSON

If you've worked in a lot of codebases, this scenario will be familiar: somewhere in the app, we're JSON-decoding a string, then using that to pass arguments to a method (such as a constructor). It may look something like this: $json = '{"first": "Steve", "last": "Grunwell"}'; $data = json_decode($json); $person = new Person($data->first, $data->last); I'd like to humbly ask that you stop doing…