Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
9 / 9
CRAP
100.00% covered (success)
100.00%
1 / 1
Filter
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
9 / 9
9
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 getLastEditInfo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getID
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUserID
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUserName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTimestamp
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHitCount
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isThrottled
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __clone
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\AbuseFilter\Filter;
4
5/**
6 * Immutable value object representing a "complete" filter. This can be used to represent filters
7 * that already exist in the database, but you should probably use subclasses for that.
8 */
9class Filter extends AbstractFilter {
10    /** @var LastEditInfo */
11    protected $lastEditInfo;
12    /** @var int|null Can be null if not specified */
13    protected $id;
14    /** @var int|null Can be null if the filter is not current */
15    protected $hitCount;
16    /** @var bool|null Can be null if the filter is not current */
17    protected $throttled;
18
19    /**
20     * @param Specs $specs
21     * @param Flags $flags
22     * @param callable|array[] $actions Array with params or callable that will return them
23     * @phan-param array[]|callable():array[] $actions
24     * @param LastEditInfo $lastEditInfo
25     * @param int|null $id
26     * @param int|null $hitCount
27     * @param bool|null $throttled
28     */
29    public function __construct(
30        Specs $specs,
31        Flags $flags,
32        $actions,
33        LastEditInfo $lastEditInfo,
34        ?int $id = null,
35        ?int $hitCount = null,
36        ?bool $throttled = null
37    ) {
38        parent::__construct( $specs, $flags, $actions );
39        $this->lastEditInfo = clone $lastEditInfo;
40        $this->id = $id;
41        $this->hitCount = $hitCount;
42        $this->throttled = $throttled;
43    }
44
45    /**
46     * @return LastEditInfo
47     */
48    public function getLastEditInfo(): LastEditInfo {
49        return clone $this->lastEditInfo;
50    }
51
52    /**
53     * @return int|null
54     */
55    public function getID(): ?int {
56        return $this->id;
57    }
58
59    /**
60     * @return int
61     */
62    public function getUserID(): int {
63        return $this->lastEditInfo->getUserID();
64    }
65
66    /**
67     * @return string
68     */
69    public function getUserName(): string {
70        return $this->lastEditInfo->getUserName();
71    }
72
73    /**
74     * @return string
75     */
76    public function getTimestamp(): string {
77        return $this->lastEditInfo->getTimestamp();
78    }
79
80    /**
81     * @return int|null
82     */
83    public function getHitCount(): ?int {
84        return $this->hitCount;
85    }
86
87    /**
88     * @return bool|null
89     */
90    public function isThrottled(): ?bool {
91        return $this->throttled;
92    }
93
94    /**
95     * Make sure we don't leave any (writeable) reference
96     */
97    public function __clone() {
98        parent::__clone();
99        $this->lastEditInfo = clone $this->lastEditInfo;
100    }
101}