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