mirror of
				https://github.com/elyby/oauth2-server.git
				synced 2025-05-31 14:12:07 +05:30 
			
		
		
		
	Scope entity is json serializable
This commit is contained in:
		| @@ -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() | ||||
|         ]; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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())); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user