Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
UserIdentityUtils
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isTemp
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isNamed
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace MediaWiki\User;
4
5use 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 */
13class 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}