public function getTotalCount(): int
    {
        if (null === $this->totalRecords) {
            if ($this->getCountMethod() === self::COUNT_METHOD_QUERY) {
                $this->totalRecords = $this->getTotalRecordsByQueryCount();
            } elseif ($this->getCountMethod() === self::COUNT_METHOD_SELECT) {
                $this->totalRecords = $this->getTotalRecordsBySelectCount();
            } elseif ($this->getCountMethod() === self::COUNT_METHOD_RECORDCOUNT) {
                $this->totalRecords = $this->getTotalRecordsByRecordCount();
            } else {
                throw new \LogicException('Cannot get a method to obtain the total count');
            }
        }
        return $this->totalRecords;
    }