Skip to content

Commit 56bcc1a

Browse files
author
Adam Rodriguez
committed
add toArray api to access token
1 parent 77def43 commit 56bcc1a

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/Token/AccessToken.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @link http://tools.ietf.org/html/rfc6749#section-1.4 Access Token (RFC 6749, §1.4)
2424
*/
25-
class AccessToken implements AccessTokenInterface, ResourceOwnerAccessTokenInterface
25+
class AccessToken implements AccessTokenInterface, ResourceOwnerAccessTokenInterface, ArrayableAccessTokenInterface
2626
{
2727
/**
2828
* @var string
@@ -214,11 +214,11 @@ public function __toString()
214214
{
215215
return (string) $this->getToken();
216216
}
217-
217+
218218
/**
219219
* @inheritdoc
220220
*/
221-
public function jsonSerialize()
221+
public function toArray()
222222
{
223223
$parameters = $this->values;
224224

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

241241
return $parameters;
242242
}
243+
244+
/**
245+
* @inheritdoc
246+
*/
247+
public function jsonSerialize()
248+
{
249+
return $this->toArray();
250+
}
243251
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace League\OAuth2\Client\Token;
4+
5+
use ReturnTypeWillChange;
6+
7+
interface ArrayableAccessTokenInterface
8+
{
9+
/**
10+
* Returns an array of parameters provided to the access token
11+
*
12+
* @return array
13+
*/
14+
#[ReturnTypeWillChange]
15+
public function toArray();
16+
}

0 commit comments

Comments
 (0)