Lines 100.00% 6 / 6
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Covered by tests of size
Name Lines Methods CRAP
 getUserName 100.00% 3 / 3 100.00% 1 / 1 1
 getRealName 100.00% 3 / 3 100.00% 1 / 1 1
28class UserNameTwigExtension extends AbstractExtension
29{
30    /**
31     * @throws Exception
32     */
33    #[AsTwigFilter(name: 'userName')]
34    public static function getUserName(int $userId): string
35    {
36        $user = new User(Configuration::getConfigurationInstance());
37        $user->getUserById($userId);
38        return $user->getLogin();
39    }
40
41    /**
42     * @throws Exception
43     */
44    #[AsTwigFilter(name: 'realName')]
45    public static function getRealName(int $userId): string
46    {
47        $user = new User(Configuration::getConfigurationInstance());
48        $user->getUserById($userId);
49        return (string) $user->getUserData(field: 'display_name');
50    }
51}