Completed
Push — master ( aa3e09...85e896 )
by Mikołaj
04:06
created

Controller   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getList() 16 16 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 Rudolf\Modules\Appearance\Roll\Admin;
4
5
use Rudolf\Component\Helpers\Pagination\Calc as Pagination;
6
use Rudolf\Framework\Controller\AdminController;
7
use Rudolf\Modules\Appearance\Roll\Admin\Model as AppearanceList;
8
9 View Code Duplication
class Controller extends AdminController
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    public function getList($page)
12
    {
13
        $page = $this->firstPageRedirect($page, 301, $location = '../../list');
14
15
        $list = new AppearanceList();
16
        $total = $list->getTotalNumber('1=1');
0 ignored issues
show
Unused Code introduced by
The call to Model::getTotalNumber() has too many arguments starting with '1=1'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
17
18
        $pagination = new Pagination($total, $page);
19
        $limit = $pagination->getLimit();
20
        $onPage = $pagination->getOnPage();
21
22
        $results = $list->getList($limit, $onPage);
0 ignored issues
show
Unused Code introduced by
The call to Model::getList() has too many arguments starting with $limit.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
23
        $view = new View();
24
        $view->setData($results, $pagination);
25
        $view->render('admin');
26
    }
27
}
28