protected function showToScreen($type, $currency, $column, $lt = false, $gt = false) { $adsStorage = new AdsStorage(); $adsStorage->addAll($this->getAdsList($type, $currency)); $adapter = new Screen($column, $lt, $gt); $adapter->setOutputColumns(self::OUTPUT_COLUMNS); $adapter->process($adsStorage); }
protected function getOutputColumns(AdsStorage $adsStorage) { $outputColumns = $this->outputColumns; if (empty($this->outputColumns)) { $adsStorage->rewind(); $ad = $adsStorage->current(); $outputColumns = $ad->getKeys(); } return $outputColumns; }
/** * @param $type * @param $currency * * @return AdsStorage * * @throws \Exception */ public function getByOperationTypeAndCurrency($type, $currency) { $adsStorage = new AdsStorage(); $curl = new Curl(); $link = sprintf(self::LINK_OPERATION_TYPE_AND_CURRENCY, $type, $currency); do { $response = $curl->get($link); if (false === $response) { throw new \Exception('Error response', 100); } $adsList = $this->getAdsList($response); if (false === empty($adsList)) { foreach ($adsList as $ad) { $adObject = new Ad($ad); $adsStorage->add($adObject); } } $link = $this->getNextLink($response); } while ($link); return $adsStorage; }