Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
PraiseworthyConditions
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 6
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 jsonSerialize
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 getMaxEdits
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMinEdits
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMaxReverts
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDays
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace GrowthExperiments\MentorDashboard\PersonalizedPraise;
4
5use JsonSerializable;
6
7class PraiseworthyConditions implements JsonSerializable {
8
9    public const SETTING_MAX_EDITS = 'maxEdits';
10    public const SETTING_MIN_EDITS = 'minEdits';
11    public const SETTING_MAX_REVERTS = 'maxReverts';
12    public const SETTING_DAYS = 'days';
13
14    /** @var int Maximum number of edits a mentee can have to be praiseworthy */
15    private int $maxEdits;
16
17    /** @var int Minimum number of edits a mentee must have to be praiseworthy */
18    private int $minEdits;
19
20    /** @var int|null Maximum number of reverted edits a mentee can have to be praiseworthy or
21     * null if the check should be skipped.
22     */
23    private ?int $maxReverts;
24
25    /**
26     * @var int
27     *
28     * To be considered praiseworthy, a mentee needs to make a certain number of edits
29     * (see $minEdits) in this amount of days to be praiseworthy.
30     */
31    private int $days;
32
33    /**
34     * @param int $maxEdits
35     * @param int $minEdits
36     * @param int|null $maxReverts
37     * @param int $days
38     */
39    public function __construct(
40        int $maxEdits,
41        int $minEdits,
42        ?int $maxReverts,
43        int $days
44    ) {
45        $this->maxEdits = $maxEdits;
46        $this->minEdits = $minEdits;
47        $this->maxReverts = $maxReverts;
48        $this->days = $days;
49    }
50
51    /** @inheritDoc */
52    public function jsonSerialize(): array {
53        return [
54            self::SETTING_MAX_EDITS => $this->maxEdits,
55            self::SETTING_MIN_EDITS => $this->minEdits,
56            self::SETTING_MAX_REVERTS => $this->maxReverts,
57            self::SETTING_DAYS => $this->days,
58        ];
59    }
60
61    /**
62     * @return int Maximum number of edits a mentee can have to be praiseworthy
63     */
64    public function getMaxEdits(): int {
65        return $this->maxEdits;
66    }
67
68    /**
69     * @return int Minimum number of edits a mentee must have to be praiseworthy
70     */
71    public function getMinEdits(): int {
72        return $this->minEdits;
73    }
74
75    /**
76     * @return int|null Maximum number of reverted edits a mentee can have to be praiseworthy.
77     * Can be null if the check should be skipped.
78     */
79    public function getMaxReverts(): ?int {
80        return $this->maxReverts;
81    }
82
83    /**
84     * @return int To be considered praiseworthy, a mentee needs to make a certain number of
85     * edits (see ::getMinEdits) in this amount of days to be praiseworthy.
86     */
87    public function getDays(): int {
88        return $this->days;
89    }
90}