Code Duplication    Length = 11-13 lines in 3 locations

src/App/Command/CreateUserCommand.php 3 locations

@@ 85-95 (lines=11) @@
82
    {
83
        $questions = [];
84
85
        if (!$input->getArgument('username')) {
86
            $question = new Question('Please choose a username:');
87
            $question->setValidator(function ($username) {
88
                if (empty($username)) {
89
                    throw new \Exception('Username can not be empty');
90
                }
91
92
                return $username;
93
            });
94
            $questions['username'] = $question;
95
        }
96
97
        if (!$input->getArgument('email')) {
98
            $question = new Question('Please choose an email:');
@@ 97-108 (lines=12) @@
94
            $questions['username'] = $question;
95
        }
96
97
        if (!$input->getArgument('email')) {
98
            $question = new Question('Please choose an email:');
99
            $question->setValidator(function ($email) {
100
                if (empty($email)) {
101
                    throw new \Exception('Email can not be empty');
102
                }
103
104
                return $email;
105
            });
106
107
            $questions['email'] = $question;
108
        }
109
110
        if (!$input->getArgument('password')) {
111
            $question = new Question('Please choose a password:');
@@ 110-122 (lines=13) @@
107
            $questions['email'] = $question;
108
        }
109
110
        if (!$input->getArgument('password')) {
111
            $question = new Question('Please choose a password:');
112
            $question->setValidator(function ($password) {
113
                if (empty($password)) {
114
                    throw new \Exception('Password can not be empty');
115
                }
116
117
                return $password;
118
            });
119
120
            $question->setHidden(true);
121
            $questions['password'] = $question;
122
        }
123
124
        foreach ($questions as $name => $question) {
125
            $answer = $this->getHelper('question')->ask($input, $output, $question);