Archived
1
0
Fork 0

app/library/OAuth/UserData/UserDataInterface.php: adding getFirstname() and getLastname()

This commit is contained in:
Henrik Hautakoski 2018-08-14 18:06:33 +02:00
parent 5d60b0f238
commit c65020fa43
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA
5 changed files with 83 additions and 4 deletions

View file

@ -46,6 +46,18 @@ class Github implements UserDataInterface
return $this->data['name'];
}
public function getFirstname()
{
$pos = strpos($this->getName(), ' ');
return $pos !== false ? substr($this->getName(), 0, $pos) : $this->getName();
}
public function getLastname()
{
$pos = strpos($this->getName(), ' ');
return $pos !== false ? substr($this->getName(), $pos+1) : null;
}
/**
* {@inheritDoc}
*/