Passed
Push — v2 ( 4bb499...14e88a )
by Daniel
05:18
created
src/Command/UserCreateCommand.php 1 patch
Upper-Lower-Casing   -84 removed lines patch added patch discarded remove patch
@@ -50,87 +50,3 @@
 block discarded – undo
50 50
                 new InputOption('overwrite', null, InputOption::VALUE_NONE, 'Overwrite the user if they already exist'),
51 51
             ])
52 52
             ->setHelp(<<<'EOT'
53
-                The <info>silverback:api-component:user:create</info> command creates a user:
54
-                  <info>php %command.full_name% daniel</info>
55
-                This interactive shell will ask you for an email and then a password.
56
-                You can alternatively specify the email and password as the second and third arguments:
57
-                  <info>php %command.full_name% daniel [email protected] mypassword</info>
58
-                You can create a super admin via the super-admin flag:
59
-                  <info>php %command.full_name% admin --super-admin</info>
60
-                You can create an inactive user (will not be able to log in):
61
-                  <info>php %command.full_name% disabled_user --inactive</info>
62
-                You can overwrite a user if they already exist:
63
-                  <info>php %command.full_name% existing_username --overwrite</info>
64
-                EOT
65
-            );
66
-    }
67
-
68
-    /**
69
-     * {@inheritdoc}
70
-     */
71
-    protected function execute(InputInterface $input, OutputInterface $output): void
72
-    {
73
-        $username = (string) $input->getArgument('username');
74
-        $email = (string) $input->getArgument('email');
75
-        $password = (string) $input->getArgument('password');
76
-        $inactive = $input->getOption('inactive');
77
-        $superadmin = $input->getOption('super-admin');
78
-        $overwrite = $input->getOption('overwrite');
79
-
80
-        $this->userFactory->create($username, $password, $email, $inactive, $superadmin, $overwrite);
81
-
82
-        $output->writeln(sprintf('Created user <comment>%s</comment>', $username));
83
-    }
84
-
85
-    /**
86
-     * {@inheritdoc}
87
-     */
88
-    protected function interact(InputInterface $input, OutputInterface $output): void
89
-    {
90
-        $this->checkUsernameQuestion($input);
91
-        $this->checkEmailQuestion($input);
92
-        $this->checkPasswordQuestion($input);
93
-
94
-        foreach ($this->questions as $name => $question) {
95
-            $answer = $this->getHelper('question')->ask($input, $output, $question);
96
-            $input->setArgument($name, $answer);
97
-        }
98
-    }
99
-
100
-    private function checkUsernameQuestion(InputInterface $input): void
101
-    {
102
-        if (!$input->getArgument('username')) {
103
-            $question = new Question('Please choose a username:');
104
-            $question->setValidator(self::getNotEmptyValidator('Username'));
105
-            $this->questions['username'] = $question;
106
-        }
107
-    }
108
-
109
-    private function checkPasswordQuestion(InputInterface $input): void
110
-    {
111
-        if (!$input->getArgument('password')) {
112
-            $question = new Question('Please choose a password:');
113
-            $question->setValidator(self::getNotEmptyValidator('Password'));
114
-            $this->questions['password'] = $question;
115
-        }
116
-    }
117
-
118
-    private function checkEmailQuestion(InputInterface $input): void
119
-    {
120
-        if (!$input->getArgument('email')) {
121
-            $question = new Question('Please choose an email (leave blank to use same as username):');
122
-            $this->questions['email'] = $question;
123
-        }
124
-    }
125
-
126
-    private static function getNotEmptyValidator(string $label): callable
127
-    {
128
-        return static function (string $string) use ($label) {
129
-            if (empty($string)) {
130
-                throw new Exception($label . ' can not be empty');
131
-            }
132
-
133
-            return $string;
134
-        };
135
-    }
136
-}
Please login to merge, or discard this patch.