app/library/OAuth/UserData/UserDataInterface.php: adding getFirstname() and getLastname()
This commit is contained in:
parent
5d60b0f238
commit
c65020fa43
5 changed files with 83 additions and 4 deletions
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class Gitlab implements UserDataInterface
|
|||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
var_dump($data);exit;
|
||||
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +48,23 @@ class Gitlab implements UserDataInterface
|
|||
return $this->data['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getFirstname()
|
||||
{
|
||||
$pos = strpos($this->getName(), ' ');
|
||||
return $pos !== false ? substr($this->getName(), 0, $pos) : $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getLastname()
|
||||
{
|
||||
$pos = strpos($this->getName(), ' ');
|
||||
return $pos !== false ? substr($this->getName(), $pos+1) : null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -46,6 +46,24 @@ class Google implements UserDataInterface
|
|||
return $this->data['displayName'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getFirstname()
|
||||
{
|
||||
$pos = strpos($this->getName(), ' ');
|
||||
return $pos !== false ? substr($this->getName(), 0, $pos) : $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getLastname()
|
||||
{
|
||||
$pos = strpos($this->getName(), ' ');
|
||||
return $pos !== false ? substr($this->getName(), $pos+1) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,15 +44,31 @@ class LinkedIn implements UserDataInterface
|
|||
public function getName()
|
||||
{
|
||||
$name = '';
|
||||
if (isset($this->data['firstName'])) {
|
||||
$name = $this->data['firstName'];
|
||||
if ($this->getFirstname() !== null) {
|
||||
$name = $this->getFirstname();
|
||||
}
|
||||
if (isset($this->data['lastName'])) {
|
||||
$name .= ' ' . $this->data['lastName'];
|
||||
if ($this->getLastname() !== null) {
|
||||
$name .= ' ' . $this->getLastname();
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getFirstname()
|
||||
{
|
||||
return isset($this->data['firstName']) ? $this->data['firstName'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getLastname()
|
||||
{
|
||||
return isset($this->data['lastName']) ? $this->data['lastName'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,6 +34,20 @@ interface UserDataInterface
|
|||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* First name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstname();
|
||||
|
||||
/**
|
||||
* Last name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastname();
|
||||
|
||||
/**
|
||||
* Email address
|
||||
*
|
||||
|
|
|
|||
Reference in a new issue