CommentController::newPostAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Schanihbg\Comment;
4
5
use \Anax\DI\InjectionAwareInterface;
6
use \Anax\DI\InjectionAwareTrait;
7
8
/**
9
 * A controller for the REM Server.
10
 *
11
 * @SuppressWarnings(PHPMD.ExitExpression)
12
 */
13
class CommentController implements InjectionAwareInterface
14
{
15
    use InjectionAwareTrait;
16
17
18
    /**
19
     * View all posts
20
     *
21
     * @return void
22
     */
23 View Code Duplication
    public function viewAll()
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...
24
    {
25
        $data = $this->di->get("comment")->viewAll();
26
27
        $this->di->get("view")->add("comment/main", ["content" => $data]);
28
        $this->di->get("pageRender")->renderPage(["title" => "All comments"]);
29
    }
30
31
    /**
32
     * New post
33
     *
34
     * @return void
35
     */
36
    public function newPost()
37
    {
38
        $this->di->get("view")->add("comment/new_comment");
39
        $this->di->get("pageRender")->renderPage(["title" => "New comment"]);
40
    }
41
42
    /**
43
     * New post page
44
     *
45
     * @return void
46
     */
47
    public function newPostAction()
48
    {
49
        $this->di->get("view")->add("comment/new_comment_action");
50
        $this->di->get("pageRender")->renderPage(["title" => "New comment action"]);
51
    }
52
53
    /**
54
     * Show one post
55
     *
56
     * @return void
57
     */
58 View Code Duplication
    public function showOnePost($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...
59
    {
60
        $data = $this->di->get("comment")->showOnePost($id);
61
62
        $this->di->get("view")->add("comment/post", ["content" => $data]);
63
        $this->di->get("pageRender")->renderPage(["title" => "Post id ".$id]);
64
    }
65
66
    /**
67
     * Edit post
68
     *
69
     * @return void
70
     */
71 View Code Duplication
    public function editPost($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...
72
    {
73
        $data = $this->di->get("comment")->editPost($id);
74
75
        $this->di->get("view")->add("comment/update_comment", ["content" => $data]);
76
        $this->di->get("pageRender")->renderPage(["title" => "Update comment"]);
77
    }
78
79
    /**
80
     * Edit post action
81
     *
82
     * @return void
83
     */
84
    public function editPostAction()
85
    {
86
        $this->di->get("view")->add("comment/update_comment_action");
87
        $this->di->get("pageRender")->renderPage(["title" => "Update comment action"]);
88
    }
89
90
    /**
91
     * Remove post
92
     *
93
     * @return void
94
     */
95
    public function removePost($id)
96
    {
97
        $this->di->get("comment")->removePost($id);
98
    }
99
}
100