Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
NewcomerTasksLog
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 count
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace GrowthExperiments\NewcomerTasks;
4
5use Wikimedia\Rdbms\SelectQueryBuilder;
6
7/**
8 * Query logging table for newcomer tasks for a specific user.
9 */
10class NewcomerTasksLog {
11
12    protected SelectQueryBuilder $queryBuilder;
13
14    /**
15     * @param SelectQueryBuilder $queryBuilder
16     */
17    public function __construct( SelectQueryBuilder $queryBuilder ) {
18        $this->queryBuilder = $queryBuilder;
19    }
20
21    /**
22     * Get the number of tasks the user has completed in the current day (for that user's timezone).
23     *
24     * @return int
25     */
26    public function count(): int {
27        return $this->queryBuilder->caller( __METHOD__ )->fetchRowCount();
28    }
29}