Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code improvements #40

Merged
merged 2 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/Provider/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace Wohali\OAuth2\Client\Provider;

use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -44,7 +46,6 @@ public function getBaseAuthorizationUrl()
* Get access token URL to retrieve token
*
* @param array $params
*
* @return string
*/
public function getBaseAccessTokenUrl(array $params)
Expand All @@ -56,7 +57,6 @@ public function getBaseAccessTokenUrl(array $params)
* Get provider URL to retrieve user details
*
* @param AccessToken $token
*
* @return string
*/
public function getResourceOwnerDetailsUrl(AccessToken $token)
Expand Down Expand Up @@ -99,10 +99,11 @@ protected function getDefaultScopes()
/**
* Check a provider response for errors.
*
* @throws IdentityProviderException
* @param ResponseInterface @response
* @param ResponseInterface $response
* @param array $data Parsed response data
* @return void
*
* @throws IdentityProviderException
*/
protected function checkResponse(ResponseInterface $response, $data)
{
Expand All @@ -114,9 +115,9 @@ protected function checkResponse(ResponseInterface $response, $data)
/**
* Generate a user object from a successful user details request.
*
* @param array $response
* @param AccessToken $token
* @return \League\OAuth2\Client\Provider\ResourceOwnerInterface
* @param array $response
* @param AccessToken $token
* @return ResourceOwnerInterface
*/
protected function createResourceOwner(array $response, AccessToken $token)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Provider/DiscordResourceOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class DiscordResourceOwner implements ResourceOwnerInterface
/**
* Creates new resource owner.
*
* @param array $response
* @param array $response
* @return void
*/
public function __construct(array $response = array())
{
Expand Down
4 changes: 1 addition & 3 deletions src/Provider/Exception/DiscordIdentityProviderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ class DiscordIdentityProviderException extends IdentityProviderException
*
* @param ResponseInterface $response
* @param array $data Parsed response data
*
* @return IdentityProviderException
*/
public static function clientException(ResponseInterface $response, $data)
{
return static::fromResponse(
$response,
isset($data['message']) ? $data['message'] : json_encode($data)
$data['message'] ?? json_encode($data)
);
}

Expand All @@ -39,7 +38,6 @@ public static function clientException(ResponseInterface $response, $data)
*
* @param ResponseInterface $response
* @param string $message
*
* @return IdentityProviderException
*/
protected static function fromResponse(ResponseInterface $response, $message = null)
Expand Down