コード例 #1
0
 /**
  * Returns a partial model of certain user defined by its userId
  * By calling this method, only the properties username, fullName, avatar and score of the User will be popullated,
  * as well as the provided userId
  *
  * @param $userId
  * @return User
  */
 public function getUserData($userId)
 {
     $response = $this->connect('GET', new Route(self::USER_ABOUT_ROUTE, ['userId' => $userId]));
     $contents = $response->getBody()->getContents();
     $responseData = $this->serializer->deserialize($contents, 'array', 'json');
     // Create the User model to be returned and populate it
     $user = new User();
     $user->fromArray($responseData['userData']);
     $user->setUserId($userId);
     return $user;
 }