We can refactor this method body a bit:

````
if ( ! isset($this->totalHits)) {
  $this->totalHits = $this->searchable->search($this->query)->getTotalHits();
}

return $this->query->hasParam('size')
    ? min($this->totalHits, (integer) $this->query->getParam('size'))
    : $this->totalHits;
```