Code Duplication    Length = 6-7 lines in 2 locations

Security/ShibbolethAuthenticationProvider.php 2 locations

@@ 67-72 (lines=6) @@
64
        $username = $token->getUsername();
65
66
        try {
67
            if ($user instanceof UserInterface) {
68
                $token->setUser($this->userProvider->refreshUser($user));
69
                $user = $token->getUser();
70
            } else {
71
                $user = $this->userProvider->loadUserByUsername($username);
72
            }
73
            if (empty($user) || !$user instanceof UserInterface) {
74
                $this->log(sprintf('User not found for username "%s"', $username));
75
                throw new AuthenticationException('Shibboleth authentication failed.');
@@ 80-86 (lines=7) @@
77
            $this->log(sprintf('User found for username "%s": %s', $username, $user));
78
79
            foreach ($token->getRoles() as $role) {
80
                if ($role instanceof SwitchUserRole) {
81
                    $source = $role->getSource();
82
                    $sourceUser = $source->getUser();
83
                    if ($sourceUser instanceof UserInterface) {
84
                        $source->setUser($this->userProvider->refreshUser($sourceUser));
85
                    }
86
                }
87
            }
88
        } catch (UsernameNotFoundException $notFound) {
89
            $this->log(sprintf('User not found for username "%s": %s', $username, $notFound->getMessage()));