LoginController::getPostLogin()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 14
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Nicklas\Comment;
4
5
// ANAX
6
use \Anax\Configure\ConfigureInterface;
7
use \Anax\Configure\ConfigureTrait;
8
use \Anax\DI\InjectionAwareInterface;
9
use \Anax\DI\InjectionAwareTrait;
10
11
// HTMLforms
12
use \Nicklas\Comment\HTMLForm\User\UserLoginForm;
13
use \Nicklas\Comment\HTMLForm\User\CreateUserForm;
14
use \Nicklas\Comment\HTMLForm\User\UserResetForm;
15
16
// MODULES
17
use \Nicklas\Comment\Modules\User;
18
19
/**
20
 * A controller class.
21
 */
22
class LoginController implements
23
    ConfigureInterface,
24
    InjectionAwareInterface
25
{
26
    use ConfigureTrait, InjectionAwareTrait;
27
28
    /**
29
     * Logout user by setting "user" == null in session.
30
     *
31
     * @return void
32
     */
33
    public function logout()
34
    {
35
        $this->di->get('session')->set("user", null);
36
        $this->di->get("response")->redirect("user/login");
37
    }
38
39
40
    /**
41
     * check if user is logged in
42
     *
43
     * @return void
44
     */
45 2
    public function checkIsLogin()
46
    {
47 2 View Code Duplication
        if (!$this->di->get("session")->has("user")) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
            $views = [
49
                ["comment/user/fail/fail", [], "main"]
50
            ];
51
            $this->di->get("pageRenderComment")->renderPage([
52
                "views" => $views,
53
                "title" => "Not logged in"
54
            ]);
55
        }
56 2
    }
57
58
59
60
61
    /**
62
     * Description.
63
     *
64
     * @throws Exception
65
     *
66
     * @return void
67
     */
68 1 View Code Duplication
    public function getPostLogin()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70 1
        $form       = new UserLoginForm($this->di);
71 1
        $form->check();
72
73
        $views = [
74 1
            ["comment/user/pre/login", ["form" => $form->getHTML()], "main"]
75 1
        ];
76
77 1
        $this->di->get("pageRenderComment")->renderPage([
78 1
            "views" => $views,
79
            "title" => "Login"
80 1
        ]);
81 1
    }
82
83
    /**
84
    * Description.
85
    *
86
    * @return void
87
    */
88 View Code Duplication
    public function getPostReset()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
    {
90
        $form       = new UserResetForm($this->di);
91
        $form->check();
92
93
        $views = [
94
            ["comment/user/pre/reset", ["form" => $form->getHTML()], "main"]
95
        ];
96
97
        $this->di->get("pageRenderComment")->renderPage([
98
            "views" => $views,
99
            "title" => "Reset password"
100
        ]);
101
    }
102
103
104
105
    /**
106
     * Description.
107
     *
108
     * @throws Exception
109
     *
110
     * @return void
111
     */
112 1 View Code Duplication
    public function getPostCreateUser()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
    {
114 1
        $form       = new CreateUserForm($this->di);
115 1
        $form->check();
116
117
        $views = [
118 1
            ["comment/user/pre/create", ["form" => $form->getHTML()], "main"]
119 1
        ];
120
121 1
        $this->di->get("pageRenderComment")->renderPage([
122 1
            "views" => $views,
123
            "title" => "Create User"
124 1
        ]);
125 1
    }
126
}
127