Skip to content

Instantly share code, notes, and snippets.

@young-steveo
Last active June 20, 2018 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save young-steveo/f8dd1288ccd025fab96848a1e3901679 to your computer and use it in GitHub Desktop.
Save young-steveo/f8dd1288ccd025fab96848a1e3901679 to your computer and use it in GitHub Desktop.
Bad Example
<?php
if (empty($data["username"])) {
throw new \Exception("Username is required.");
}
if (empty($data["name"])) {
$first = $data["first_name"] ?? '';
$last = $data["last_name"] ?? '';
$data["name"] = "$first $last";
}
$params = new SearchParams($data['username'], $data['name']);
$model = new User();
$result = $model->search($params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment