Passed
Push — master ( 17b30a...9c28de )
by Mihail
14:15
created

User::actionRecovery()   C

Complexity

Conditions 10
Paths 8

Size

Total Lines 69
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 35
nc 8
nop 2
dl 0
loc 69
rs 6.0493
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Apps\Controller\Front;
4
5
use Apps\ActiveRecord\Invite;
6
use Apps\ActiveRecord\UserRecovery;
7
use Apps\Model\Front\User\FormLogin;
8
use Apps\Model\Front\User\FormPasswordChange;
9
use Apps\Model\Front\User\FormRecovery;
10
use Apps\Model\Front\User\FormRegister;
11
use Apps\Model\Front\User\FormSocialAuth;
12
use Extend\Core\Arch\FrontAppController;
13
use Ffcms\Core\App;
14
use Ffcms\Core\Exception\ForbiddenException;
15
use Ffcms\Core\Exception\NativeException;
16
use Ffcms\Core\Exception\NotFoundException;
17
use Ffcms\Core\Exception\SyntaxException;
18
use Ffcms\Core\Helper\Type\Any;
19
use Ffcms\Core\Helper\Type\Obj;
20
use Ffcms\Core\Helper\Type\Str;
21
22
/**
23
 * Class User - standard user controller: login/signup/logout/etc
24
 * @package Apps\Controller\Front
25
 */
26
class User extends FrontAppController
27
{
28
    const EVENT_USER_LOGIN_SUCCESS = 'user.login.success';
29
    const EVENT_USER_LOGIN_FAIL = 'user.login.fail';
30
    const EVENT_USER_REGISTER_SUCCESS = 'user.signup.success';
31
    const EVENT_USER_REGISTER_FAIL = 'user.signup.fail';
32
    const EVENT_USER_RECOVERY_SUCCESS = 'user.recovery.success';
33
34
    use User\ActionLogin {
35
        login as actionLogin;
36
    }
37
38
    use User\ActionSignup {
39
        signup as actionSignup;
40
    }
41
42
    use User\ActionSocialAuth {
43
        socialauth as actionSocialauth;
44
    }
45
46
    use User\ActionRecovery {
47
        recovery as actionRecovery;
48
    }
49
50
    use User\ActionApprove {
51
        approve as actionApprove;
52
    }
53
54
    /**
55
     * Make logout if user is signIn
56
     * @throws ForbiddenException
57
     */
58
    public function actionLogout()
59
    {
60
        // check if user authorized
61
        if (!App::$User->isAuth()) {
62
            throw new ForbiddenException(__('You are not authorized user'));
63
        }
64
65
        // unset session data
66
        App::$Session->invalidate();
67
68
        // redirect to main
69
        $this->response->redirect('/');
70
    }
71
}
72