Completed
Push — master ( 9c0f6d...e28c7c )
by Alexey
37:38
created

LogoutAction::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace yiicod\auth\actions\webUser;
4
5
use Yii;
6
use yii\base\Action;
7
use yii\base\ActionEvent;
8
use yii\base\Event;
9
10
/**
11
 * Login action
12
 *
13
 * @author Orlov Alexey <[email protected]>
14
 */
15
class LogoutAction extends Action
16
{
17
    const EVENT_BEFORE_LOGOUT = 'beforeLogout';
18
    const EVENT_AFTER_LOGOUT = 'afterLogout';
19
20
    public $view = '';
21
22
    /**
23
     * Logs out the current user and redirect to homepage.
24
     */
25
    public function run()
26
    {
27
        Event::trigger(self::class, static::EVENT_BEFORE_LOGOUT, new ActionEvent($this, ['sender' => $this]));
28
29
        Yii::$app->user->logout();
30
31
        Event::trigger(self::class, static::EVENT_AFTER_LOGOUT, new ActionEvent($this, ['sender' => $this]));
32
33
        return Yii::$app->controller->goHome();
34
    }
35
36
//    public function trigger($name, Event $event = null)
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
//    {
38
//        Yii::$app->trigger(sprintf('yiicod.auth.actions.webUser.LogoutAction.%s', $name), $event);
39
40
//        return parent::trigger($name, $event);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
//    }
42
}
43