Completed
Push — master ( 4d2acf...6494fd )
by Nicklas
02:04
created

UserController::getPostReset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 14
loc 14
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 2
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 UserController 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 1
                ["user/fail/fail", [], "main"]
50 1
            ];
51 1
            $this->di->get("pageRenderComment")->renderPage([
52 1
                "views" => $views,
53
                "title" => "Not logged in"
54 1
            ]);
55 1
        }
56 2
    }
57
58
59
60
61
    /**
62
     * Description.
63
     *
64
     * @param datatype $variable Description
0 ignored issues
show
Bug introduced by
There is no parameter named $variable. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
65
     *
66
     * @throws Exception
67
     *
68
     * @return void
69
     */
70 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...
71
    {
72 1
        $form       = new UserLoginForm($this->di);
73 1
        $form->check();
74
75
        $views = [
76 1
            ["user/pre/login", ["form" => $form->getHTML()], "main"]
77 1
        ];
78
79 1
        $this->di->get("pageRenderComment")->renderPage([
80 1
            "views" => $views,
81
            "title" => "Login"
82 1
        ]);
83 1
    }
84
85
    /**
86
    * Description.
87
    *
88
    * @return void
89
    */
90 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...
91
    {
92
        $form       = new UserResetForm($this->di);
93
        $form->check();
94
95
        $views = [
96
            ["user/pre/reset", ["form" => $form->getHTML()], "main"]
97
        ];
98
99
        $this->di->get("pageRenderComment")->renderPage([
100
            "views" => $views,
101
            "title" => "Reset password"
102
        ]);
103
    }
104
105
106
107
    /**
108
     * Description.
109
     *
110
     * @param datatype $variable Description
0 ignored issues
show
Bug introduced by
There is no parameter named $variable. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
111
     *
112
     * @throws Exception
113
     *
114
     * @return void
115
     */
116 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...
117
    {
118 1
        $form       = new CreateUserForm($this->di);
119 1
        $form->check();
120
121
        $views = [
122 1
            ["user/pre/create", ["form" => $form->getHTML()], "main"]
123 1
        ];
124
125 1
        $this->di->get("pageRenderComment")->renderPage([
126 1
            "views" => $views,
127
            "title" => "Create User"
128 1
        ]);
129 1
    }
130
}
131