Пример #1
0
 public function testCanParseCorrectJson()
 {
     // Arrange
     $response = new HttpResponse('http://waltertamboer.nl', 200, '{}');
     // Act
     $value = $response->getJsonObject();
     // Assert
     $this->assertInstanceOf('stdClass', $value);
 }
Пример #2
0
 public function getStoryDataWrapper(HttpResponse $response)
 {
     $jsonObject = $response->getJsonObject();
     $dataContainer = new DataContainer\StoryDataContainer();
     $this->initializeDataContainer($dataContainer, $jsonObject->data);
     $dataWrapper = new DataWrapper\StoryDataWrapper();
     $dataWrapper->setData($dataContainer);
     $this->initializeDataWrapper($dataWrapper, $jsonObject);
     foreach ($jsonObject->data->results as $dataObject) {
         $item = new Entity\Story();
         $item->setId($dataObject->id);
         $item->setTitle($dataObject->title);
         $item->setDescription($dataObject->description);
         $item->setResourceURI($dataObject->resourceURI);
         $item->setType($dataObject->type);
         $item->setModified($dataObject->modified);
         $item->setThumbnail($this->parseImage($dataObject->thumbnail));
         $item->setComics($this->parseComics($dataObject->comics));
         $item->setSeries($this->parseSeries($dataObject->series));
         $item->setEvents($this->parseEvents($dataObject->events));
         $item->setCharacters($this->parseCharacters($dataObject->characters));
         $item->setCreators($this->parseCreators($dataObject->creators));
         $item->setOriginalissue($this->parseComicSummary($dataObject->originalIssue));
         $dataContainer->add($item);
     }
     return $dataWrapper;
 }