Exemplo n.º 1
0
 /**
  * @return \Triquanta\IziTravel\DataType\CountryInterface[]
  */
 public function execute()
 {
     $json = $this->requestHandler->get('/countries', ['languages' => $this->languageCodes, 'includes' => $this->includes, 'form' => $this->form, 'limit' => $this->limit, 'offset' => $this->offset]);
     $data = json_decode($json);
     $countries = [];
     foreach ($data as $countryData) {
         $countries[] = CountryBase::createFromJson(json_encode($countryData), $this->form);
     }
     return $countries;
 }
Exemplo n.º 2
0
 /**
  * @return \Triquanta\IziTravel\DataType\MtgObjectInterface[]|\Triquanta\IziTravel\DataType\CityInterface[]|\Triquanta\IziTravel\DataType\CountryInterface[]
  */
 public function execute()
 {
     $json = $this->requestHandler->get('/mtg/objects/search/', ['languages' => $this->languageCodes, 'includes' => $this->includes, 'form' => $this->form, 'sort_by' => $this->sort, 'type' => $this->types, 'query' => $this->query, 'limit' => $this->limit, 'offset' => $this->offset, 'region' => $this->region]);
     $data = json_decode($json);
     $objects = [];
     foreach ($data as $objectData) {
         if ($objectData->type === 'city') {
             $objects[] = CityBase::createFromJson(json_encode($objectData), $this->form);
         } elseif ($objectData->type === 'country') {
             $objects[] = CountryBase::createFromJson(json_encode($objectData), $this->form);
         } else {
             $objects[] = MtgObjectBase::createFromJson(json_encode($objectData), $this->form);
         }
     }
     return $objects;
 }
Exemplo n.º 3
0
 /**
  * @return \Triquanta\IziTravel\DataType\CountryInterface
  */
 public function execute()
 {
     $json = $this->requestHandler->get('/countries/' . $this->uuid, ['languages' => $this->languageCodes, 'includes' => $this->includes, 'form' => $this->form]);
     return CountryBase::createFromJson($json, $this->form);
 }
Exemplo n.º 4
0
 /**
  * @covers ::createFromJson
  * @covers ::createFromData
  */
 public function testCreateFromData()
 {
     $this->assertInstanceOf('\\Triquanta\\IziTravel\\DataType\\FullCountryInterface', CountryBase::createFromJson(TestHelper::getJsonResponse('country_full_include_all'), MultipleFormInterface::FORM_FULL));
     $this->assertInstanceOf('\\Triquanta\\IziTravel\\DataType\\CompactCountryInterface', CountryBase::createFromJson(TestHelper::getJsonResponse('country_compact_include_all'), MultipleFormInterface::FORM_COMPACT));
 }