MediaWiki master
UserIdentityUtils.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\User;
4
6
17 public function __construct(
18 private readonly TempUserConfig $tempUserConfig,
19 ) {
20 }
21
28 public function isTemp( UserIdentity $user ) {
29 return $this->tempUserConfig->isTempName( $user->getName() );
30 }
31
38 public function isNamed( UserIdentity $user ) {
39 return $user->isRegistered()
40 && !$this->tempUserConfig->isTempName( $user->getName() );
41 }
42
51 public function getShortUserTypeInternal( UserIdentity $user ): string {
52 if ( !$user->isRegistered() ) {
53 return 'anon';
54 }
55 return $this->isTemp( $user ) ? 'temp' : 'named';
56 }
57}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
Convenience functions for interpreting UserIdentity objects using additional services or config.
__construct(private readonly TempUserConfig $tempUserConfig,)
isNamed(UserIdentity $user)
Is the user a normal non-temporary registered user?
getShortUserTypeInternal(UserIdentity $user)
Get user identity type, used for internal logic like tracking statistics per account type.
isTemp(UserIdentity $user)
Is the user a temporary user?
Interface for temporary user creation config and name matching.
Interface for objects representing user identity.
isRegistered()
This must be equivalent to getId() != 0 and is provided for code readability.