app/library/OAuth/UserData: make all concrete classes extend UserData.
This commit is contained in:
parent
4a22f67e62
commit
43417740a7
4 changed files with 24 additions and 243 deletions
|
|
@ -2,67 +2,18 @@
|
|||
|
||||
namespace Httpcb\OAuth\UserData;
|
||||
|
||||
class Github implements UserDataInterface
|
||||
class Github extends UserData
|
||||
{
|
||||
protected $data;
|
||||
protected $_provider = 'Github';
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getProvider()
|
||||
{
|
||||
return 'Github';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return (int) $this->data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->data['login'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
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}
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->data['email'];
|
||||
$this->_id = $data['id'];
|
||||
$this->_username = $data['login'];
|
||||
$this->_name = $data['name'];
|
||||
$this->_email = $data['email'];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue