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