src/AbstractQueue.php
final public function count(array $query, bool $running = null) : int
    {
        $totalQuery = [];

        if ($running === true || $running === false) {
            $key = $running ? '$gt' : '$lte';
            $totalQuery['earliestGet'] = [$key => new UTCDateTime((int)(microtime(true) * 1000))];
        }

        return $this->collection->count($this->buildPayloadQuery($totalQuery, $query));
    }
final public function count(array $query, bool $running = null) : int
    {
        $totalQuery = [];

        if ($running === true || $running === false) {
            $key = $running ? '$gt' : '$lte';
            $totalQuery['earliestGet'] = [$key => new UTCDateTime((int)(microtime(true) * 1000))];
        }

        return $this->collection->count($this->buildPayloadQuery($totalQuery, $query));
    }
Count queue messages.

@param array $query in same format as \MongoDB\Collection::find() where top level fields do not contain
operators. Lower level fields can however. eg: valid {a: {$gt: 1}, "b.c": 3},
invalid {$and: [{...}, {...}]}
@param bool|null $running query a running message or not or all

@return int the count

@throws \InvalidArgumentException key in $query was not a string