firebase - Can I count item in firestore using php

one text

I want to count all items I have in the database can I use something instead of that

 public static function count($column, $value)
    {
        $data = self::$db->collection("problems");
        $query = $data->where($column, '=', $value);
        $documents = $query->documents();
        $total = 0;
        foreach ($documents as $document) {
            if ($document->exists()) {
                $total++;
            }
        }
        return $total;
    }

Source