Code Duplication    Length = 21-21 lines in 2 locations

src/WebBundle/Command/GitkiUsersCommand.php 2 locations

@@ 107-127 (lines=21) @@
104
     *
105
     * @return User
106
     */
107
    protected function editUsername(
108
        InputInterface $input,
109
        OutputInterface $output,
110
        User $user,
111
        QuestionHelper $questionHelper
112
    ) {
113
        $realNameQuestion = new Question('Username [required]: ');
114
        $realNameQuestion->setValidator(
115
            function ($answer) {
116
                if (empty($answer)) {
117
                    throw new \RuntimeException('Username must not be empty');
118
                }
119
120
                return $answer;
121
            }
122
        );
123
        $realNameQuestion->setMaxAttempts(2);
124
        $user->setUsername($questionHelper->ask($input, $output, $realNameQuestion));
125
126
        return $user;
127
    }
128
129
    /**
130
     * @param InputInterface  $input
@@ 167-187 (lines=21) @@
164
     *
165
     * @return User
166
     */
167
    protected function editEmail(
168
        InputInterface $input,
169
        OutputInterface $output,
170
        User $user,
171
        QuestionHelper $questionHelper
172
    ) {
173
        $emailQuestion = new Question('Email [required]: ');
174
        $emailQuestion->setValidator(
175
            function ($answer) {
176
                if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
177
                    throw new \RuntimeException("This is not a valid email address");
178
                }
179
180
                return $answer;
181
            }
182
        );
183
        $emailQuestion->setMaxAttempts(2);
184
        $user->setEmail($questionHelper->ask($input, $output, $emailQuestion));
185
186
        return $user;
187
    }
188
189
    /**
190
     * @param InputInterface  $input