Completed
Push — master ( 0a436d...ec1a89 )
by Nicklas
02:25
created

UserController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 32.56 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 14
loc 43
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllUsersIndex() 14 14 1
A getUserIndex() 0 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Nicklas\Comment;
4
5
// MODULES
6
use \Nicklas\Comment\Modules\User;
7
8
/**
9
 * A controller class.
10
 */
11
class UserController extends ProfileController
12
{
13
14
    /**
15
     * Create page for all users overview
16
     *
17
     * @return void
18
     */
19 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...
20
    {
21
        $user = new User($this->di->get("db"));
22
        $users = $user->getAllUsers();
23
24
        $views = [
25
            ["comment/users/view-all", ["users" => $users], "main"]
26
        ];
27
28
        $this->di->get("pageRenderComment")->renderPage([
29
            "views" => $views,
30
            "title" => "Coffee users"
31
        ]);
32
    }
33
34
    /**
35
     * Create page for all users overview
36
     *
37
     * @return void
38
     */
39
    public function getUserIndex($name)
40
    {
41
        $user = new User($this->di->get("db"));
42
        $user = $user->getUser($name);
43
44
        $views = [
45
            ["comment/users/view-user", ["user" => $user], "main"]
46
        ];
47
48
        $this->di->get("pageRenderComment")->renderPage([
49
            "views" => $views,
50
            "title" => "User | $user->name"
51
        ]);
52
    }
53
}
54