Test Failed
Push — master ( 10865e...d038e5 )
by Simon
10:06
created

UserController::adminControl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Schanihbg\User;
4
5
use \Anax\Configure\ConfigureInterface;
6
use \Anax\Configure\ConfigureTrait;
7
use \Anax\DI\InjectionAwareInterface;
8
use \Anax\Di\InjectionAwareTrait;
9
use \Schanihbg\User\HTMLForm\UserLoginForm;
10
use \Schanihbg\User\HTMLForm\CreateUserForm;
11
use \Schanihbg\User\HTMLForm\UpdateUserForm;
12
13
/**
14
 * A controller class.
15
 */
16
class UserController implements
17
    ConfigureInterface,
18
    InjectionAwareInterface
19
{
20
    use ConfigureTrait,
21
        InjectionAwareTrait;
22
23
24
25
    /**
26
     * @var $data description
27
     */
28
    //private $data;
29
30
31
32
    /**
33
     * Description.
34
     *
35
     * @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...
36
     *
37
     * @throws Exception
38
     *
39
     * @return void
40
     */
41 View Code Duplication
    public function getIndex()
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...
42
    {
43
        $title      = "User profile";
44
        $view       = $this->di->get("view");
45
        $pageRender = $this->di->get("pageRender");
46
47
        $view->add("user/profile");
48
49
        $pageRender->renderPage(["title" => $title]);
50
    }
51
52
53
54
    /**
55
     * Description.
56
     *
57
     * @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...
58
     *
59
     * @throws Exception
60
     *
61
     * @return void
62
     */
63 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...
64
    {
65
        $title      = "A login page";
66
        $view       = $this->di->get("view");
67
        $pageRender = $this->di->get("pageRender");
68
        $form       = new UserLoginForm($this->di);
69
70
        $form->check();
71
72
        $data = [
73
            "content" => $form->getHTML(),
74
        ];
75
76
        $view->add("default2/article", $data);
77
78
        $pageRender->renderPage(["title" => $title]);
79
    }
80
81
82
83
    /**
84
     * Description.
85
     *
86
     * @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...
87
     *
88
     * @throws Exception
89
     *
90
     * @return void
91
     */
92 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...
93
    {
94
        $title      = "A create user page";
95
        $view       = $this->di->get("view");
96
        $pageRender = $this->di->get("pageRender");
97
        $form       = new CreateUserForm($this->di);
98
99
        $form->check();
100
101
        $data = [
102
            "content" => $form->getHTML(),
103
        ];
104
105
        $view->add("default2/article", $data);
106
107
        $pageRender->renderPage(["title" => $title]);
108
    }
109
110
    /**
111
     * Handler with form to update a user.
112
     *
113
     * @return void
114
     */
115 View Code Duplication
    public function getPostUpdateUser($id)
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...
116
    {
117
        $title      = "Update an item";
118
        $view       = $this->di->get("view");
119
        $pageRender = $this->di->get("pageRender");
120
        $form       = new UpdateUserForm($this->di, $id);
121
122
        $form->check();
123
124
        $data = [
125
            "form" => $form->getHTML(),
126
            "id" => $id,
127
        ];
128
129
        $view->add("user/update", $data);
130
131
        $pageRender->renderPage(["title" => $title]);
132
    }
133
134
    /**
135
     * Description.
136
     *
137
     * @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...
138
     *
139
     * @throws Exception
140
     *
141
     * @return void
142
     */
143
    public function loginUser($input)
144
    {
145
        $this->di->get("session")->set("userLoggedIn", $input);
146
    }
147
148
    /**
149
     * Description.
150
     *
151
     * @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...
152
     *
153
     * @throws Exception
154
     *
155
     * @return void
156
     */
157 View Code Duplication
    public function logoutUser()
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...
158
    {
159
        $title      = "Logout page";
160
        $view       = $this->di->get("view");
161
        $pageRender = $this->di->get("pageRender");
162
163
        $view->add("user/logout");
164
165
        $pageRender->renderPage(["title" => $title]);
166
    }
167
168
    /**
169
     * Description.
170
     *
171
     * @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...
172
     *
173
     * @throws Exception
174
     *
175
     * @return void
176
     */
177 View Code Duplication
    public function getIDByUser($userInput)
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...
178
    {
179
        $user = new User();
180
        $user->setDb($this->di->get("database"));
181
        $user->find("acronym", $userInput);
182
183
        return $user;
184
    }
185
186
    /**
187
     * Description.
188
     *
189
     * @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...
190
     *
191
     * @throws Exception
192
     *
193
     * @return void
194
     */
195
    public function adminControl()
196
    {
197
        $title      = "Admin Control";
198
        $view       = $this->di->get("view");
199
        $pageRender = $this->di->get("pageRender");
200
201
        $sql = "SELECT * FROM `User`";
202
203
        $data = $this->di->get("database")->executeFetchAll($sql);
204
205
        $view->add("user/admin", ["content" => $data]);
206
207
        $pageRender->renderPage(["title" => $title]);
208
    }
209
210
    /**
211
     * Delete user
212
     *
213
     * @return void
214
     */
215
    public function removeUser($id)
216
    {
217
        $sql = "DELETE FROM `User` WHERE id = ?";
218
        $this->di->get("database")->execute($sql, [$id]);
219
        $this->di->get("response")->redirect($this->di->get("url")->create("user/admin"));
220
    }
221
}
222