Skip to content

Commit

Permalink
add Name::getAll() and polish test
Browse files Browse the repository at this point in the history
  • Loading branch information
wyrfel committed May 10, 2015
1 parent fafda79 commit 5005350
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 165 deletions.
15 changes: 15 additions & 0 deletions src/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ public function getParts()
return $this->parts;
}

public function getAll()
{
$results = [];
$keys = ['salutation', 'firstname', 'middlename', 'lastname', 'nickname', 'initials', 'suffix'];

foreach ($keys as $key) {
$method = sprintf('get%s', ucfirst($key));
if ($value = call_user_func(array($this, $method))) {
$results[$key] = $value;
};
}

return $results;
}

/**
* get the first name
*
Expand Down
Loading

0 comments on commit 5005350

Please sign in to comment.