Code Duplication    Length = 9-9 lines in 5 locations

src/Util/UserManipulator.php 5 locations

@@ 94-102 (lines=9) @@
91
     *
92
     * @param string $username
93
     */
94
    public function activate($username)
95
    {
96
        $user = $this->findUserByUsernameOrThrowException($username);
97
        $user->setEnabled(true);
98
        $this->userManager->updateUser($user);
99
100
        $event = new UserEvent($user, $this->getRequest());
101
        $this->dispatcher->dispatch(Events::USER_ACTIVATED, $event);
102
    }
103
104
    /**
105
     * Deactivates the given user.
@@ 109-117 (lines=9) @@
106
     *
107
     * @param string $username
108
     */
109
    public function deactivate($username)
110
    {
111
        $user = $this->findUserByUsernameOrThrowException($username);
112
        $user->setEnabled(false);
113
        $this->userManager->updateUser($user);
114
115
        $event = new UserEvent($user, $this->getRequest());
116
        $this->dispatcher->dispatch(Events::USER_DEACTIVATED, $event);
117
    }
118
119
    /**
120
     * Changes the password for the given user.
@@ 125-133 (lines=9) @@
122
     * @param string $username
123
     * @param string $password
124
     */
125
    public function changePassword($username, $password)
126
    {
127
        $user = $this->findUserByUsernameOrThrowException($username);
128
        $user->setPlainPassword($password);
129
        $this->userManager->updateUser($user);
130
131
        $event = new UserEvent($user, $this->getRequest());
132
        $this->dispatcher->dispatch(Events::USER_PASSWORD_CHANGED, $event);
133
    }
134
135
    /**
136
     * Promotes the given user.
@@ 140-148 (lines=9) @@
137
     *
138
     * @param string $username
139
     */
140
    public function promote($username)
141
    {
142
        $user = $this->findUserByUsernameOrThrowException($username);
143
        $user->setSuperAdmin(true);
144
        $this->userManager->updateUser($user);
145
146
        $event = new UserEvent($user, $this->getRequest());
147
        $this->dispatcher->dispatch(Events::USER_PROMOTED, $event);
148
    }
149
150
    /**
151
     * Demotes the given user.
@@ 155-163 (lines=9) @@
152
     *
153
     * @param string $username
154
     */
155
    public function demote($username)
156
    {
157
        $user = $this->findUserByUsernameOrThrowException($username);
158
        $user->setSuperAdmin(false);
159
        $this->userManager->updateUser($user);
160
161
        $event = new UserEvent($user, $this->getRequest());
162
        $this->dispatcher->dispatch(Events::USER_DEMOTED, $event);
163
    }
164
165
    /**
166
     * Adds role to the given user.