adding app/library/OAuth/UserData classes (interface and Github implementation)
This commit is contained in:
parent
556a62b34b
commit
21c869a06a
2 changed files with 99 additions and 0 deletions
56
app/library/OAuth/UserData/Github.php
Normal file
56
app/library/OAuth/UserData/Github.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Httpcb\OAuth\UserData;
|
||||
|
||||
class Github implements UserDataInterface
|
||||
{
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* {@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'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->data['email'];
|
||||
}
|
||||
}
|
||||
43
app/library/OAuth/UserData/UserDataInterface.php
Normal file
43
app/library/OAuth/UserData/UserDataInterface.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Httpcb\OAuth\UserData;
|
||||
|
||||
interface UserDataInterface
|
||||
{
|
||||
public function __construct(array $data);
|
||||
|
||||
/**
|
||||
* The providers name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProvider();
|
||||
|
||||
/**
|
||||
* Owners ID (userid)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* the username
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername();
|
||||
|
||||
/**
|
||||
* Full name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Email address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail();
|
||||
}
|
||||
Reference in a new issue