public function save(Place $place) { $this->requestType = 'savePlace'; $this->getPath(); $placeJsonString = $this->config->getRestClient()->execute($this->request); $this->setup(); $placeJsonObject = json_decode($placeJsonString); return PlaceFactory::generate($placeJsonObject->place); }
public static function generate($placeListJsonObject) { if (is_object($placeListJsonObject)) { $placeList = new PlaceList(); $placeList->setNumFound($placeListJsonObject->result_count); $placeList->setCurrentPage($placeListJsonObject->current_page); foreach ($placeListJsonObject->places as $place) { $placeList->add(PlaceFactory::generate($place->place)); } if (isset($placeListJsonObject->facets)) { $placeList->setFacets(FacetsFactory::generate($placeListJsonObject->facets)); } return $placeList; } else { throw new ChegamosException("Parâmetro passado não é um objeto."); } }
public function testGenerateWithoutData() { try { PlaceFactory::generate(null); } catch (ChegamosException $e) { $this->assertEquals("Parâmetro data não é um objeto.", $e->getMessage()); return; } $this->fail('An expected exception has not been raised.'); }