Completed
Push — master ( d84616...0f723a )
by Nicklas
02:09
created

UserController::getPostEditComment()   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 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 View Code Duplication
    public function getAllUsersIndex()
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...
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
        $user = $user->getUser($name);
46
47
        $views = [
48
            ["comment/users/view-user", ["user" => $user], "main"]
49
        ];
50
51
        $this->di->get("pageRenderComment")->renderPage([
52
            "views" => $views,
53
            "title" => "User | $user->name"
54
        ]);
55
    }
56
57
    /**
58
     * Create page for all users overview
59
     *
60
     * @return void
61
     */
62 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...
63
    {
64
        $form = new EditPostForm($this->di, $id);
65
        $form->check();
66
67
        $views = [
68
            ["comment/default-form", ["form" => $form->getHTML()], "main"]
69
        ];
70
71
        $this->di->get("pageRenderComment")->renderPage([
72
            "views" => $views,
73
            "title" => "Edit post | $id"
74
        ]);
75
    }
76
    /**
77
     * Create page for all users overview
78
     *
79
     * @return void
80
     */
81 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...
82
    {
83
        $form = new EditCommentForm($this->di, $id);
84
        $form->check();
85
86
        $views = [
87
            ["comment/default-form", ["form" => $form->getHTML()], "main"]
88
        ];
89
90
        $this->di->get("pageRenderComment")->renderPage([
91
            "views" => $views,
92
            "title" => "Edit comment | $id"
93
        ]);
94
    }
95
}
96