예제 #1
0
 /**
  * Test CreateFromLeagueName
  * @return void
  */
 public function testCreateFromLeagueName()
 {
     $leagueAndGroup = LeagueAndGroup::CreateFromLeagueName("Herren Aktive GF 1. Liga");
     $this->assertEquals(3, $leagueAndGroup->getLeagueId());
     $this->assertEquals("GF", $leagueAndGroup->getLeagueType());
 }
예제 #2
0
 public function getLeagueByTeam($team)
 {
     $response = $this->guzzle->get(WP_SUAPI_ENDPOINT_GAMES . "?season=" . $this->yearForQuery . "&mode=team" . "&team_id=" . $team->getTeamId());
     if ($response->getStatusCode() !== 200) {
         throw new WP_SUAPI_Api_Exception($response->getBody());
     }
     $leagueAndGroup = new LeagueAndGroup($team->getTeamName());
     $leagueId = json_decode($response->getBody())->data->tabs[0]->link->ids[1];
     $gameClassId = json_decode($response->getBody())->data->tabs[0]->link->ids[2];
     $leagueAndGroup->setLeagueId($leagueId);
     $leagueAndGroup->setLeagueGameClassId($gameClassId);
     $parsedLeagueGroup = array();
     if (preg_match("/.*Gr\\.\\s(\\d*)/", json_decode($response->getBody())->data->title, $parsedLeagueGroup)) {
         $leagueGroup = $parsedLeagueGroup[1];
         $leagueAndGroup->setLeagueGroup($leagueGroup);
     }
     return $leagueAndGroup;
 }