/** * Constructor * * Supported params for $options are:- * * lastRun = (string|DateTime) The datetime for updated_at or deleted_at * * startPage = (int) which page to start the pagination loop * * perPage = (int) how many items to fetch per page. Max 100 per API * * showProgress = (bool) whether or not to output progress * * showMemory = (bool) whether or not to output memory statistics * * @param TicketEvolution\Webservice $webService TicketEvolution\Webservice object to use for API calls * @param array $options Array of options */ public function __construct(Webservice $webService, array $options = array()) { // Set the startTime to now $this->_startTime = new DateTime(); // Reference to the webService object $this->_webService = $webService; // Set the status row to store the completed progress $this->_setStatusRow(); /** * Process the $options */ if (!empty($options['startPage'])) { $this->_startPage = $options['startPage']; } if (!empty($options['perPage'])) { $this->_perPage = $options['perPage']; } if (isset($options['showMemory'])) { $this->_showMemory = (bool) $options['showMemory']; } if (isset($options['showProgress'])) { $this->_showProgress = (bool) $options['showProgress']; } $this->_originalOptions = $options; /** * Set the date we last ran this script so we can get only entries that have * been added/changed/deleted since then */ if (!empty($options['lastRun'])) { if (!$options['lastRun'] instanceof DateTime) { if (!($this->_lastRun = new DateTime($options['lastRun']))) { throw new namespace\Exception('The $lastRun date you provided appears to be malformed'); } } else { $this->_lastRun = $options['lastRun']; } } else { // The table should have either a previously set value // OR a default date of 2010-01-01 for the column $this->_lastRun = new DateTime($this->_statusRow->lastRun); } /** * Convert $_lastRun to UTC because the API currently ignores the time if it is * not specified as UTC. This is not expected behavior and should be fixed soon. */ $this->_lastRun->setTimezone(new DateTimeZone('UTC')); }