public function valid()
{
if (is_null($this->jql)) {
throw new \Exception('you have to call Jira_Walker::push($jql, $fields) at first');
}
if (!$this->executed) {
try {
$result = $this->api->search($this->getQuery(), $this->key(), $this->perPage, $this->fields);
$this->setResult($result);
$this->executed = true;
if ($result->getTotal() == 0) {
return false;
}
return true;
} catch (Api\UnauthorizedException $e) {
throw $e;
} catch (\Exception $e) {
error_log($e->getMessage());
return false;
}
} else {
if ($this->offset >= $this->max && $this->key() < $this->total) {
try {
$result = $this->api->search($this->getQuery(), $this->key(), $this->perPage, $this->fields);
$this->setResult($result);
return true;
} catch (Api\UnauthorizedException $e) {
throw $e;
} catch (\Exception $e) {
error_log($e->getMessage());
return false;
}
} else {
if (($this->startAt - 1) * $this->perPage + $this->offset < $this->total) {
return true;
} else {
return false;
}
}
}
}