/** * Parse the data * @param array $data shall be the response body * @param string $type data type */ public function process(array $data, $type, $parentId = null) { try { if (empty($this->mappers[$type])) { if (empty($this->fallback)) { throw new UserException("Mapper for type '{$type}' has not been configured."); } return $this->fallback->process($data, $type, (array) $parentId); } return $this->mappers[$type]->parse($data, (array) $parentId); } catch (BadConfigException $e) { throw new UserException("Bad Json to CSV Mapping configuration: " . $e->getMessage(), 0, $e); } catch (BadDataException $e) { throw new UserException("Error saving '{$type}' data to CSV column: " . $e->getMessage(), 0, $e, $e->getData()); } }
/** * Parse the result into a CSV (either using any of built-in parsers, or using own methods). * * @param object $response * @param array $parentId ID (or list thereof) to be passed to parser */ protected function parse(array $data, array $parentId = null) { $this->parser->process($data, $this->getDataType(), $parentId); }