コード例 #1
0
 public function testGetTypesList()
 {
     $list = Achievement::getAllTypesList();
     $this->assertCount(4, $list);
     $this->assertTrue(in_array(Achievement::TYPE_BADGE, $list));
     $this->assertTrue(in_array(Achievement::TYPE_LEVEL, $list));
     $this->assertTrue(in_array(Achievement::TYPE_POINTS, $list));
     $this->assertTrue(in_array(Achievement::TYPE_QUEST, $list));
 }
コード例 #2
0
 /**
  * Returns the number of achievements of each type for certain user
  *
  * @param User|string $user A User model or userId
  * @param array|string $types List of types in a comma-separated string or array.
  *          All the types will be returned by default
  * @return Collection|Achievement[]
  */
 public function getUserAchievements($user, $types = [])
 {
     $userId = $user instanceof User ? $user->getUserId() : $user;
     $types = empty($types) ? Achievement::getAllTypesList() : $types;
     $types = is_array($types) ? implode(',', $types) : $types;
     return $this->getResourceCollection(new Route(self::USER_ACHIEVEMENTS_ROUTE, ['userId' => $userId], ['types' => $types]), 'achievements', 'Wonnova\\SDK\\Model\\Achievement');
 }