chobie\Jira\Issues\Walker::valid PHP Method

valid() public method

Checks if current position is valid.
public valid ( ) : boolean
return boolean The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.
    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;
                }
            }
        }
    }