code: public function count()
      {
          if ($this->queryShouldBeStopped) {
              return 0;
          }
  
          $filter = $this->normalizeFilter();
          $queryType = "ElementQuery::count";
  
          $callback = function () use ($filter) {
              return (int) $this->bxObject->GetList(false, $filter, []);
          };
  
          return $this->handleCacheIfNeeded(compact('filter', 'queryType'), $callback);
      }
docs: Get count of elements that match $filter.
  
  @return int