Skip to content

Commit

Permalink
add toArray api to access token
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Rodriguez committed Dec 7, 2021
1 parent 77def43 commit 1eccc08
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Token/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @link http://tools.ietf.org/html/rfc6749#section-1.4 Access Token (RFC 6749, §1.4)
*/
class AccessToken implements AccessTokenInterface, ResourceOwnerAccessTokenInterface
class AccessToken implements AccessTokenInterface, ResourceOwnerAccessTokenInterface, ArrayableAccessTokenInterface
{
/**
* @var string
Expand Down Expand Up @@ -214,11 +214,11 @@ public function __toString()
{
return (string) $this->getToken();
}

/**
* @inheritdoc
*/
public function jsonSerialize()
public function toArray()
{
$parameters = $this->values;

Expand All @@ -240,4 +240,12 @@ public function jsonSerialize()

return $parameters;
}

/**
* @inheritdoc
*/
public function jsonSerialize()
{
return $this->toArray();
}
}
16 changes: 16 additions & 0 deletions src/Token/ArrayableAccessTokenInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace League\OAuth2\Client\Token;

use ReturnTypeWillChange;

interface ArrayableAccessTokenInterface
{
/**
* Returns an array of parameters provided to the access token
*
* @return array
*/
#[ReturnTypeWillChange]
public function toArray();
}

0 comments on commit 1eccc08

Please sign in to comment.