Debian Codegraph @

includes/user/UserIdentityUtils.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\User;
4
5 use MediaWiki\User\TempUser\TempUserConfig;
6
7 /**
8 * Convenience functions for interpreting UserIdentity objects using additional
9 * services or config.
10 *
11 * @since 1.41
12 */
13 class UserIdentityUtils {
14 private TempUserConfig $tempUserConfig;
15
16 /**
17 * @internal
18 *
19 * @param TempUserConfig $tempUserConfig
20 */
21 public function __construct( TempUserConfig $tempUserConfig ) {
22 $this->tempUserConfig = $tempUserConfig;
23 }
24
25 /**
26 * Is the user a temporary user?
27 *
28 * @param UserIdentity $user
29 * @return bool
30 */
31 public function isTemp( UserIdentity $user ) {
32 return $this->tempUserConfig->isTempName( $user->getName() );
33 }
34
35 /**
36 * Is the user a normal non-temporary registered user?
37 *
38 * @param UserIdentity $user
39 * @return bool
40 */
41 public function isNamed( UserIdentity $user ) {
42 return $user->isRegistered()
43 && !$this->tempUserConfig->isTempName( $user->getName() );
44 }
45 }