Merge "RCFilters: Don't load JS or redirect when transcluding"
[lhc/web/wiklou.git] / includes / user / UserIdentityValue.php
1 <?php
2 /**
3 * Value object representing a user's identity.
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
23 namespace MediaWiki\User;
24
25 use Wikimedia\Assert\Assert;
26
27 /**
28 * Value object representing a user's identity.
29 *
30 * @since 1.31
31 */
32 class UserIdentityValue implements UserIdentity {
33
34 /**
35 * @var int
36 */
37 private $id;
38
39 /**
40 * @var string
41 */
42 private $name;
43
44 /**
45 * @param int $id
46 * @param string $name
47 */
48 public function __construct( $id, $name ) {
49 Assert::parameterType( 'integer', $id, '$id' );
50 Assert::parameterType( 'string', $name, '$name' );
51
52 $this->id = $id;
53 $this->name = $name;
54 }
55
56 /**
57 * @return int The user ID. May be 0 for anonymous users or for users with no local account.
58 */
59 public function getId() {
60 return $this->id;
61 }
62
63 /**
64 * @return string The user's logical name. May be an IPv4 or IPv6 address for anonymous users.
65 */
66 public function getName() {
67 return $this->name;
68 }
69
70 }