Skip to content

Commit aa5c17a

Browse files
committed
Backport Token#payload()
1 parent 2cfa548 commit aa5c17a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Token.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,24 @@ private function getValidatableClaims()
391391
/**
392392
* Returns the token payload
393393
*
394+
* @deprecated This method has been removed from the interface in v4.0
395+
* @see Token::payload()
396+
*
394397
* @return string
395398
*/
396399
public function getPayload()
397400
{
398-
return $this->headers->toString() . '.'
399-
. $this->claims->toString();
401+
return $this->payload();
402+
}
403+
404+
/**
405+
* Returns the token payload
406+
*
407+
* @return string
408+
*/
409+
public function payload()
410+
{
411+
return $this->headers->toString() . '.' . $this->claims->toString();
400412
}
401413

402414
/** @return Signature */

test/unit/TokenTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class TokenTest extends \PHPUnit\Framework\TestCase
3838
* @covers ::getClaims
3939
* @covers ::signature
4040
* @covers ::getPayload
41+
* @covers ::payload
4142
*/
4243
public function constructMustInitializeAnEmptyPlainTextTokenWhenNoArgumentsArePassed()
4344
{
@@ -312,6 +313,7 @@ public function verifyShouldReturnFalseWhenTokenAlgorithmIsDifferent()
312313
*
313314
* @covers ::verify
314315
* @covers ::getPayload
316+
* @covers ::payload
315317
*/
316318
public function verifyMustDelegateTheValidationToSignature()
317319
{
@@ -961,6 +963,7 @@ public function isExpiredShouldReturnTrueAfterTokenExpires()
961963
* @uses \Lcobucci\JWT\Token::convertToDataSet
962964
*
963965
* @covers ::getPayload
966+
* @covers ::payload
964967
*/
965968
public function getPayloadShouldReturnAStringWithTheTwoEncodePartsThatGeneratedTheToken()
966969
{

0 commit comments

Comments
 (0)