59 lines
909 B
PHP
59 lines
909 B
PHP
<?php
|
|
|
|
namespace Httpcb\OAuth\UserData;
|
|
|
|
class Google implements UserDataInterface
|
|
{
|
|
protected $data;
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function __construct(array $data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function getProvider()
|
|
{
|
|
return 'Google';
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function getId()
|
|
{
|
|
return (int) $this->data['id'];
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function getUsername()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->data['displayName'];
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function getEmail()
|
|
{
|
|
if (isset($this->data['emails'][0]['value'])) {
|
|
return $this->data['emails'][0]['value'];
|
|
}
|
|
return null;
|
|
}
|
|
}
|