コード例 #1
0
 /**
  * Test Get/Set, create, endpoint methods.
  */
 public function testGameListEntity()
 {
     $gameList = GameList::create();
     $this->assertInstanceOf('Shoko\\TwitchApiBundle\\Model\\Entity\\GameList', $gameList);
     $this->assertEquals(array(), $gameList->getLinks());
     $link = 'some_link';
     $this->assertEquals([$link], $gameList->setLinks([$link])->getLinks());
     $this->assertEquals(array(), $gameList->getGames());
     $game = new Game();
     $this->assertEquals([$game], $gameList->setGames([$game])->getGames());
 }
コード例 #2
0
 /**
  * @param array          $data
  * @param false|GameList $gameList
  *
  * @return GameList
  */
 public function createList(array $data, $gameList = false)
 {
     if (false === $gameList) {
         $gameList = GameList::create();
     }
     if (isset($data['games'])) {
         $gameList = $gameList->setGames($this->createGames($data['games']));
     }
     if (isset($data['_links'])) {
         $gameList = $gameList->setLinks($data['_links']);
     }
     return $gameList;
 }
コード例 #3
0
 /**
  * @param array            $data
  * @param false|GameList $gameList
  *
  * @return GameList
  */
 public function createGameList(array $data, $gameList = false)
 {
     if (false === $gameList) {
         $gameList = GameList::create();
     }
     if (isset($data['follows'])) {
         $gameList = $gameList->setGames((new TopFactory())->createRanks($data['follows']));
     }
     if (isset($data['_links'])) {
         $gameList = $gameList->setLinks($data['_links']);
     }
     if (isset($data['_total'])) {
         $gameList = $gameList->setTotal($data['_total']);
     }
     return $gameList;
 }