Skip to content

Commit 2e9d41e

Browse files
committed
Incapsulated dates.
1 parent f3b181c commit 2e9d41e

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

src/Gwt/Client.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,16 @@ public function getTableData($tableName)
210210
return $this->downloadCSV_XTRA(
211211
$this->getWebsite(),
212212
$tableName,
213-
$this->_dateStart,
214-
$this->_dateEnd
213+
$this->getDateStart(),
214+
$this->getDateEnd()
215215
);
216216
break;
217217
default: // TOP_QUERIES || TOP_PAGES
218218
$downloadUrls = $this->getDownloadUrls($this->getWebsite());
219219
$finalUrl = $downloadUrls[$tableName] . '&prop=ALL&db=%s&de=%s&more=true';
220220
$finalUrl = sprintf(
221221
$finalUrl,
222-
$this->_dateStart->format('Ymd'), $this->_dateEnd->format('Ymd')
222+
$this->getDateStart()->format('Ymd'), $this->getDateEnd()->format('Ymd')
223223
);
224224
return $this->getData($finalUrl);
225225
}
@@ -393,6 +393,36 @@ public function setDateRange(DateTime $dateStart, DateTime $dateEnd)
393393
return $this;
394394
}
395395

396+
/**
397+
* Get date start value
398+
*
399+
* @throws Exception
400+
* @return DateTime
401+
*/
402+
public function getDateStart()
403+
{
404+
if (null === $this->_dateStart) {
405+
throw new Exception('You must set a dateStart value.');
406+
}
407+
408+
return $this->_dateStart;
409+
}
410+
411+
/**
412+
* Get date end value
413+
*
414+
* @throws Exception
415+
* @return DateTime
416+
*/
417+
public function getDateEnd()
418+
{
419+
if (null === $this->_dateEnd) {
420+
throw new Exception('You must set a dateEnd value.');
421+
}
422+
423+
return $this->_dateEnd;
424+
}
425+
396426
/**
397427
* Returns array of downloaded filenames.
398428
*
@@ -637,7 +667,7 @@ public function downloadCSV($site, $savepath = '.')
637667
$tables = $this->_tables;
638668
foreach ($tables as $table) {
639669
$this->saveData(
640-
$this->getTableData($table, $site, $this->_dateStart, $this->_dateEnd, $this->getLanguage()),
670+
$this->getTableData($table, $site, $this->getDateStart(), $this->getDateEnd(), $this->getLanguage()),
641671
"$savepath/$table-$filename.csv"
642672
);
643673
}

0 commit comments

Comments
 (0)