Code Duplication    Length = 32-34 lines in 2 locations

risoluto/cli/RisolutoCli/AuthManager.php 2 locations

@@ 133-164 (lines=32) @@
130
     *
131
     * @return    void    なし
132
     */
133
    private function addUser()
134
    {
135
        // 登録に必要な情報を順番に取得していく
136
        $option[ 'by_who' ] = 'Risoluto CLI - ' . RISOLUTOCLI_SELF;
137
        $option[ 'status' ] = 1;
138
139
        do {
140
            $option[ 'userid' ] = $this->readFromStdin( "Enter user id: " );
141
        } while (empty( $option[ 'userid' ] ));
142
        do {
143
            $option[ 'username' ] = $this->readFromStdin( "Enter user name: " );
144
        } while (empty( $option[ 'username' ] ));
145
        do {
146
            $option[ 'password' ] = $this->readFromStdin( "Enter user password: ", false );
147
            $option[ 'password_again' ] = $this->readFromStdin( "Enter user password again: ", false );
148
        } while (empty( $option[ 'password' ] ) or $option[ 'password' ] != $option[ 'password_again' ]);
149
        do {
150
            $option[ 'groupno' ] = $this->readFromStdin( "Enter group no: " );
151
        } while (empty( $option[ 'groupno' ] ) or !is_numeric( $option[ 'groupno' ] ));
152
153
        // 確認メッセージを表示し、承諾した場合のみ処理を実行する
154
        $enter = $this->readFromStdin( "Add this user data. Continue?[y/N]" );
155
        if (strtolower( $enter ) == 'y') {
156
            if (\Risoluto\Auth::callProviderMethod( 'addUser', $option )) {
157
                echo "All OK!" . PHP_EOL;
158
            } else {
159
                echo "Oops! Error happened." . PHP_EOL;
160
            }
161
        } else {
162
            echo "Canceled." . PHP_EOL;
163
        }
164
    }
165
166
    /**
167
     * addGroup()
@@ 214-247 (lines=34) @@
211
     *
212
     * @return    void    なし
213
     */
214
    private function modUser()
215
    {
216
        // 変更処理に必要な情報を順番に取得していく
217
        $option[ 'by_who' ] = 'Risoluto CLI - ' . RISOLUTOCLI_SELF;
218
219
        do {
220
            $option[ 'userid' ] = $this->readFromStdin( "Enter user id: " );
221
        } while (empty( $option[ 'userid' ] ));
222
        do {
223
            $option[ 'username' ] = $this->readFromStdin( "Enter user name: " );
224
        } while (empty( $option[ 'username' ] ));
225
        do {
226
            $option[ 'password' ] = $this->readFromStdin( "Enter user password: ", false );
227
            $option[ 'password_again' ] = $this->readFromStdin( "Enter user password again: ", false );
228
        } while (empty( $option[ 'password' ] ) or $option[ 'password' ] != $option[ 'password_again' ]);
229
        do {
230
            $option[ 'groupno' ] = $this->readFromStdin( "Enter group no: " );
231
        } while (empty( $option[ 'groupno' ] ) or !is_numeric( $option[ 'groupno' ] ));
232
        do {
233
            $option[ 'status' ] = $this->readFromStdin( "Enter status: " );
234
        } while (!is_numeric( $option[ 'status' ] ));
235
236
        // 確認メッセージを表示し、承諾した場合のみ処理を実行する
237
        $enter = $this->readFromStdin( "Modify this user data. Continue?[y/N]" );
238
        if (strtolower( $enter ) == 'y') {
239
            if (\Risoluto\Auth::callProviderMethod( 'modUser', $option )) {
240
                echo "All OK!" . PHP_EOL;
241
            } else {
242
                echo "Oops! Error happened." . PHP_EOL;
243
            }
244
        } else {
245
            echo "Canceled." . PHP_EOL;
246
        }
247
    }
248
249
    /**
250
     * modGroup()