3 namespace MediaWiki\User
;
5 use MediaWiki\User\TempUser\TempUserConfig
;
8 * Convenience functions for interpreting UserIdentity objects using additional
13 class UserIdentityUtils
{
14 private TempUserConfig
$tempUserConfig;
19 * @param TempUserConfig $tempUserConfig
21 public function __construct( TempUserConfig
$tempUserConfig ) {
22 $this->tempUserConfig
= $tempUserConfig;
26 * Is the user a temporary user?
28 * @param UserIdentity $user
31 public function isTemp( UserIdentity
$user ) {
32 return $this->tempUserConfig
->isTempName( $user->getName() );
36 * Is the user a normal non-temporary registered user?
38 * @param UserIdentity $user
41 public function isNamed( UserIdentity
$user ) {
42 return $user->isRegistered()
43 && !$this->tempUserConfig
->isTempName( $user->getName() );
47 * Get user identity type, used for internal logic like tracking statistics per account type.
48 * Only for internal use like tracking statistics and meet DRY
51 * @param UserIdentity $user
54 public function getShortUserTypeInternal( UserIdentity
$user ): string {
55 if ( !$user->isRegistered() ) {
58 return $this->isTemp( $user ) ?
'temp' : 'named';