Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
EditData
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 8
72
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 getEditCountByNamespace
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEditCountByDay
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRevertedEditCount
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNewcomerTaskEditCount
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEditCountByTaskType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLastEditTimestamp
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEditedArticles
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace GrowthExperiments\UserImpact;
4
5/**
6 * Value object for containing edit data related to a user's impact.
7 */
8class EditData {
9    private array $editCountByNamespace;
10    private array $editCountByDay;
11    private array $editCountByTaskType;
12    private int $revertedEditCount;
13    private int $newcomerTaskEditCount;
14    private ?string $lastEditTimestamp;
15    private array $editedArticles;
16
17    /**
18     * @param int[] $editCountByNamespace Number of edits made by the user per namespace ID.
19     * @param int[] $editCountByDay Number of article-space edits made by the user
20     *   by day. The format matches {@see UserImpact::getEditCountByDay()}.
21     * @param array<string,int> $editCountByTaskType Number of newcomer task edits per task type
22     *  {@see UserImpact::getEditCountByTaskType()}.
23     * @param int $revertedEditCount Number of edits by the user that got reverted (determined by
24     * the mw-reverted tag).
25     * @param int $newcomerTaskEditCount Number of edits with "newcomer task" tag (suggested edits).
26     * @param string|null $lastEditTimestamp MW_TS date of last article-space edit.
27     * @param array[] $editedArticles List of article-space titles the user has edited, sorted from
28     *   most recently edited to least recently edited. Keyed by article title (in dbkey format),
29     *   the value is an array with 'oldestEdit' and 'newestEdit' fields, each with an MW_TS date.
30     */
31    public function __construct(
32        array $editCountByNamespace,
33        array $editCountByDay,
34        array $editCountByTaskType,
35        int $revertedEditCount,
36        int $newcomerTaskEditCount,
37        ?string $lastEditTimestamp,
38        array $editedArticles
39    ) {
40        $this->editCountByNamespace = $editCountByNamespace;
41        $this->editCountByDay = $editCountByDay;
42        $this->editCountByTaskType = $editCountByTaskType;
43        $this->revertedEditCount = $revertedEditCount;
44        $this->newcomerTaskEditCount = $newcomerTaskEditCount;
45        $this->lastEditTimestamp = $lastEditTimestamp;
46        $this->editedArticles = $editedArticles;
47        $this->editCountByTaskType = $editCountByTaskType;
48    }
49
50    /**
51     * Number of edits made by the user per namespace.
52     * @return int[] Namespace ID => edit count.
53     */
54    public function getEditCountByNamespace(): array {
55        return $this->editCountByNamespace;
56    }
57
58    /**
59     * Number of article-space edits made by the user by day.
60     * Days are interpreted according to the wiki's timezone default offset.
61     * @return int[] Same as UserImpact::getEditCountByDay().
62     * @see $wgLocalTZoffset
63     */
64    public function getEditCountByDay(): array {
65        return $this->editCountByDay;
66    }
67
68    /**
69     * Number of total edits by the user that got reverted (determined
70     * by the mw-reverted tag).
71     * @return int
72     */
73    public function getRevertedEditCount(): int {
74        return $this->revertedEditCount;
75    }
76
77    /**
78     * Number of edits with "newcomer task" tag (suggested edits).
79     * @return int
80     */
81    public function getNewcomerTaskEditCount(): int {
82        return $this->newcomerTaskEditCount;
83    }
84
85    /**
86     * Number of newcomer task edits, grouped by task type.
87     *
88     * @return array<string,int>
89     */
90    public function getEditCountByTaskType(): array {
91        return $this->editCountByTaskType;
92    }
93
94    /**
95     * MW_TS date of last article-space edit.
96     * @return string|null
97     */
98    public function getLastEditTimestamp(): ?string {
99        return $this->lastEditTimestamp;
100    }
101
102    /**
103     * List of article-space titles the user has edited, sorted from most recently edited
104     * to least recently edited. Keyed by article title (in dbkey format), the value is an
105     * array with 'oldestEdit' and 'newestEdit' fields, each with an MW_TS date.
106     * @return array[]
107     */
108    public function getEditedArticles(): array {
109        return $this->editedArticles;
110    }
111
112}