3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 namespace MediaWiki\Permissions
;
23 use MediaWiki\User\UserIdentity
;
26 * Represents the subject that rate limits are applied to.
31 class RateLimitSubject
{
48 /** @var string Flag indicating the user is exempt from rate limits */
49 public const EXEMPT
= 'exempt';
51 /** @var string Flag indicating the user is a newbie */
52 public const NEWBIE
= 'newbie';
57 * @param UserIdentity $user
58 * @param string|null $ip
59 * @param array<string,bool> $flags
61 public function __construct( UserIdentity
$user, ?
string $ip, array $flags ) {
64 $this->flags
= $flags;
67 public function getUser(): UserIdentity
{
71 public function getIP(): ?
string {
76 * Checks whether the given flag applies.
82 public function is( string $flag ) {
83 return !empty( $this->flags
[$flag] );