UserController::getPostEditPost()   A
last analyzed

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 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Nicklas\Comment;
4
5
// MODULES
6
use \Nicklas\Comment\Modules\User;
7
use \Nicklas\Comment\Modules\Post;
8
use \Nicklas\Comment\HTMLForm\Comment\EditPostForm;
9
use \Nicklas\Comment\HTMLForm\Comment\EditCommentForm;
10
11
/**
12
 * A controller class.
13
 */
14
class UserController extends ProfileController
15
{
16
17
    /**
18
     * Create page for all users overview
19
     *
20
     * @return void
21
     */
22
    public function getAllUsersIndex()
23
    {
24
        $user = new User($this->di->get("db"));
25
        $users = $user->getAllUsers();
26
27
        $views = [
28
            ["comment/users/view-all", ["users" => $users], "main"]
29
        ];
30
31
        $this->di->get("pageRenderComment")->renderPage([
32
            "views" => $views,
33
            "title" => "Coffee users"
34
        ]);
35
    }
36
37
    /**
38
     * Create page for all users overview
39
     *
40
     * @return void
41
     */
42
    public function getUserIndex($name)
43
    {
44
        $user = new User($this->di->get("db"));
45
46
        // No exists, return false
47
        if ($user->find("name", $name) == null) {
48
            return false;
49
        }
50
51
        $user = $user->getUser($name);
52
53
        $views = [
54
            ["comment/users/view-user", ["user" => $user], "main"]
55
        ];
56
57
        $this->di->get("pageRenderComment")->renderPage([
58
            "views" => $views,
59
            "title" => "User | $user->name"
60
        ]);
61
    }
62
63
    /**
64
     * Create page for all users overview
65
     *
66
     * @return void
67
     */
68 View Code Duplication
    public function getPostEditPost($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...
69
    {
70
        $form = new EditPostForm($this->di, $id);
71
        $form->check();
72
73
        $views = [
74
            ["comment/default-form", ["form" => $form->getHTML()], "main"]
75
        ];
76
77
        $this->di->get("pageRenderComment")->renderPage([
78
            "views" => $views,
79
            "title" => "Edit post | $id"
80
        ]);
81
    }
82
    /**
83
     * Create page for all users overview
84
     *
85
     * @return void
86
     */
87 View Code Duplication
    public function getPostEditComment($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...
88
    {
89
        $form = new EditCommentForm($this->di, $id);
90
        $form->check();
91
92
        $views = [
93
            ["comment/default-form", ["form" => $form->getHTML()], "main"]
94
        ];
95
96
        $this->di->get("pageRenderComment")->renderPage([
97
            "views" => $views,
98
            "title" => "Edit comment | $id"
99
        ]);
100
    }
101
}
102