mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
Scope entity is json serializable
This commit is contained in:
parent
b9cedc8b93
commit
d40ee11ef5
@ -16,7 +16,7 @@ use League\OAuth2\Server\AbstractServer;
|
|||||||
/**
|
/**
|
||||||
* Scope entity class
|
* Scope entity class
|
||||||
*/
|
*/
|
||||||
class ScopeEntity
|
class ScopeEntity implements \JsonSerializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Scope identifier
|
* Scope identifier
|
||||||
@ -89,4 +89,16 @@ class ScopeEntity
|
|||||||
{
|
{
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a JSON object when entity is passed into json_encode
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->getId(),
|
||||||
|
'description' => $this->getDescription()
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,7 @@ class ScopeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals('foobar', $scope->getId());
|
$this->assertEquals('foobar', $scope->getId());
|
||||||
$this->assertEquals('barfoo', $scope->getDescription());
|
$this->assertEquals('barfoo', $scope->getDescription());
|
||||||
|
|
||||||
|
$this->assertTrue(is_array($scope->jsonSerialize()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user