Scope entity is json serializable

This commit is contained in:
Alex Bilbie 2014-05-08 11:55:04 +01:00
parent b9cedc8b93
commit d40ee11ef5
2 changed files with 15 additions and 1 deletions

View File

@ -16,7 +16,7 @@ use League\OAuth2\Server\AbstractServer;
/**
* Scope entity class
*/
class ScopeEntity
class ScopeEntity implements \JsonSerializable
{
/**
* Scope identifier
@ -89,4 +89,16 @@ class ScopeEntity
{
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()
];
}
}

View File

@ -16,5 +16,7 @@ class ScopeTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('foobar', $scope->getId());
$this->assertEquals('barfoo', $scope->getDescription());
$this->assertTrue(is_array($scope->jsonSerialize()));
}
}