Code Duplication    Length = 30-30 lines in 2 locations

commands/DefaultController.php 2 locations

@@ 66-95 (lines=30) @@
63
     * Block user
64
     * @param string $email user email to block
65
     */
66
    public function actionBlock($email = null)
67
    {
68
        if (empty($email)) {
69
            $this->showUsage('email');
70
        }
71
        $user = $this->findUser($email);
72
        $nameString = $this->ansiFormat($user->name, Console::FG_GREEN);
73
        $emailString = $this->ansiFormat($user->email, Console::FG_GREEN);
74
        if (!$user->isActive()) {
75
            $this->showErrors([
76
                'error' => [
77
                    Yii::t('activeuser_backend', "Can't block user {name} with email {email}", [
78
                        'name' => $nameString,
79
                        'email' => $emailString,
80
                    ])
81
                ]
82
            ]);
83
        }
84
        $this->confirmAction(Yii::t("activeuser_backend", "Block user {name} with email {email}?", [
85
            'name' => $nameString,
86
            'email' => $emailString,
87
        ]));
88
        $user->block($this->sendEmail);
89
        $this->stdout(
90
            Yii::t('activeuser_backend', 'User {name} with email {email} was blocked', [
91
                'name' => $nameString,
92
                'email' => $emailString,
93
            ]) . PHP_EOL
94
        );
95
    }
96
97
    /**
98
     * Unblock user
@@ 101-130 (lines=30) @@
98
     * Unblock user
99
     * @param string $email user email to unblock
100
     */
101
    public function actionUnblock($email = null)
102
    {
103
        if (empty($email)) {
104
            $this->showUsage('email');
105
        }
106
        $user = $this->findUser($email);
107
        $nameString = $this->ansiFormat($user->name, Console::FG_GREEN);
108
        $emailString = $this->ansiFormat($user->email, Console::FG_GREEN);
109
        if (!$user->isBlocked()) {
110
            $this->showErrors([
111
                'error' => [
112
                    Yii::t('activeuser_backend', 'User {name} with email {email} not blocked', [
113
                        'name' => $nameString,
114
                        'email' => $emailString,
115
                    ])
116
                ]
117
            ]);
118
        }
119
        $this->confirmAction(Yii::t("activeuser_backend", 'Unblock user {name} with email {email}?', [
120
            'name' => $nameString,
121
            'email' => $emailString,
122
        ]));
123
        $user->unblock($this->sendEmail);
124
        $this->stdout(
125
            Yii::t('activeuser_backend', 'User {name} with email {email} was unblocked', [
126
                'name' => $nameString,
127
                'email' => $emailString,
128
            ]) . PHP_EOL
129
        );
130
    }
131
132
    /**
133
     * Change user password