<?php
 namespace Krombox\OAuth2\Client\Provider; use League\OAuth2\Client\Provider\ResourceOwnerInterface; use League\OAuth2\Client\Tool\ArrayAccessorTrait; class WordPressResourceOwner implements ResourceOwnerInterface { use ArrayAccessorTrait; protected $response; public function __construct(array $response = array()) { $this->response = $response; } public function getId() { return $this->getValueByKey($this->response, 'id'); } public function getEmail() { return $this->getValueByKey($this->response, 'email'); } public function getUsername() { return $this->getValueByKey($this->response, 'username'); } public function getLink() { return $this->getValueByKey($this->response, 'link'); } public function getAvatarUrl($size = 96) { $avatarUrls = $this->getValueByKey($this->response, 'avatar_urls'); return in_array($size, array('24','48','96')) ? $avatarUrls[$size] : null; } public function toArray() { return $this->response; } } 