Passed
Push — master ( 76fde7...d6d75c )
by Magnus
01:55
created

OverviewController::getCatName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Radchasay\Overview;
4
5
use \Anax\Configure\ConfigureInterface;
6
use \Anax\Configure\ConfigureTrait;
7
use \Anax\DI\InjectionAwareInterface;
8
use \Anax\Di\InjectionAwareTrait;
9
use \Radchasay\Comment\Post;
10
use \Radchasay\Comment\Comment;
11
use \Radchasay\Comment\CommentComments;
12
use \Radchasay\Overview\Overview;
13
use \Radchasay\Comment\PostCategory;
14
15
/**
16
 * A controller class.
17
 */
18
class OverviewController implements
19
    ConfigureInterface,
20
    InjectionAwareInterface
21
{
22
    use ConfigureTrait,
23
        InjectionAwareTrait;
24
25
26
    /**
27
     * @var $data description
28
     */
29
    //private $data;
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 = "A index page";
44
        $view = $this->di->get("view");
45
        $pageRender = $this->di->get("pageRender");
46
        $db = $this->di->get("db");
47
48
        $user = new User();
49
        $user->setDb($db);
50
        $res = $user->getInformationLimit(5);
51
52
        var_dump($res);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($res); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
53
54
        $data = [
55
            "content" => "An index page",
56
        ];
57
58
        $view->add("default1/article", $data);
59
60
        $pageRender->renderPage(["title" => $title]);
61
    }
62
63
    public function overview()
64
    {
65
        $title = "Overview";
66
        $view = $this->di->get("view");
67
        $pageRender = $this->di->get("pageRender");
68
69
        $posts = $this->getPosts();
70
71
        $allPosts = [];
72
73 View Code Duplication
        foreach ($posts as $p) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
74
            array_push($allPosts, [$p, $this->getTags([$p->postid])]);
75
        }
76
77
        $data = [
78
            "items" => $this->getUsers(),
79
            "posts" => $allPosts,
80
            "popularTags" => $this->getPopularTags()
81
        ];
82
83
        $view->add("overview/overview", $data);
84
85
        $pageRender->renderPage(["title" => $title]);
86
    }
87
88 View Code Duplication
    public function getUsers()
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...
89
    {
90
        $overview = new Overview();
91
92
        $data = $overview->returnLimitUsers($this->di->get("db"), "points desc", 5);
93
94
        return $data;
95
    }
96
97
    public function getPosts()
98
    {
99
        $overview = new Overview();
100
101
        $data = $overview->returnLimitPosts($this->di->get("db"));
102
103
        return $data;
104
    }
105
106 View Code Duplication
    public function getTags($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...
107
    {
108
        $overview = new Overview();
109
110
        $data = $overview->returnAllTagsFromPost($this->di->get("db"), [$id]);
111
112
        return $data;
113
    }
114
115
    public function getPopularTags()
116
    {
117
        $overview = new Overview();
118
119
        $data = $overview->returnPopularTags($this->di->get("db"));
120
121
        return $data;
122
    }
123
124 View Code Duplication
    public function getCatName($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...
125
    {
126
        $postcat = new PostCategory();
127
        $postcat->setDb($this->di->get("db"));
128
        $res = $postcat->getCatName($id);
129
        return $res;
130
    }
131
}
132