Skip to content

Instantly share code, notes, and snippets.

@young-steveo
Last active June 20, 2018 14:47
Show Gist options
  • Save young-steveo/1de63da3880a35d692b03d49df188619 to your computer and use it in GitHub Desktop.
Save young-steveo/1de63da3880a35d692b03d49df188619 to your computer and use it in GitHub Desktop.
Array Oriented Programming
<?php
final class User extends Requester {
public function search(array $params) : array {
if (empty($params["username"])) {
throw new \Exception("Username is required.");
}
if (empty($params["name"])) {
$first = $params["first_name"] ?? '';
$last = $params["last_name"] ?? '';
$params["name"] = "$first $last";
}
return $this->request($params)->toArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment