1<?php
2/**
3 * Block restriction interface.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23namespace MediaWiki\Block\Restriction;
24
25interface Restriction {
26
27	/**
28	 * Gets the id of the block.
29	 *
30	 * @since 1.33
31	 * @return int
32	 */
33	public function getBlockId();
34
35	/**
36	 * Sets the id of the block.
37	 *
38	 * @since 1.33
39	 * @param int $blockId
40	 * @return self
41	 */
42	public function setBlockId( $blockId );
43
44	/**
45	 * Gets the value of the restriction.
46	 *
47	 * @since 1.33
48	 * @return int
49	 */
50	public function getValue();
51
52	/**
53	 * Gets the type of restriction
54	 *
55	 * @since 1.33
56	 * @return string
57	 */
58	public static function getType();
59
60	/**
61	 * Gets the id of the type of restriction. This id is used in the database.
62	 *
63	 * @since 1.33
64	 * @return int
65	 */
66	public static function getTypeId();
67
68	/**
69	 * Creates a new Restriction from a database row.
70	 *
71	 * @since 1.33
72	 * @param \stdClass $row
73	 * @return static
74	 */
75	public static function newFromRow( \stdClass $row );
76
77	/**
78	 * Convert a restriction object into a row array for insertion.
79	 *
80	 * @since 1.33
81	 * @return array
82	 */
83	public function toRow();
84
85	/**
86	 * Determine if a restriction matches a given title.
87	 *
88	 * @since 1.33
89	 * @param \Title $title
90	 * @return bool
91	 */
92	public function matches( \Title $title );
93
94	/**
95	 * Determine if a restriction equals another restriction.
96	 *
97	 * @since 1.33
98	 * @param Restriction $other
99	 * @return bool
100	 */
101	public function equals( Restriction $other );
102
103	/**
104	 * Create a unique hash of the block restriction based on the type and value.
105	 *
106	 * @since 1.33
107	 * @return string
108	 */
109	public function getHash();
110
111}
112