DLpaginateReversed   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 12
eloc 23
dl 0
loc 53
ccs 0
cts 27
cp 0
rs 10
c 2
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A renderItemTPL() 0 4 1
A getPageQuery() 0 15 5
A get_pagenum_link() 0 14 6
1
<?php
2
3
/**
4
 * Class DLpaginate
5
 */
6
class DLpaginateReversed extends DLpaginate
7
{
8
9
    /**
10
     * @param $page
11
     * @return int|mixed
12
     */
13
    protected function getPageQuery($page)
14
    {
15
        switch ($this->mode) {
16
            case 'offset':
17
                $display = isset($this->modeConfig['display']) ? $this->modeConfig['display'] : 0;
18
                $out = $display * ($this->total_pages - $page);
19
                break;
20
            case 'back':
21
            case 'pages':
22
            default:
23
                $out = $page;
24
                break;
25
        }
26
27
        return $out;
28
    }
29
30
    /**
31
     * @param $tpl
32
     * @param $num
33
     * @return mixed
34
     */
35
    protected function renderItemTPL($tpl, $num)
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
36
    {
37
        $_num = $this->total_pages + 1 - $num;
38
        return str_replace(array('[+num+]', '[+link+]'), array($_num, $this->get_pagenum_link($_num)), $tpl);
39
    }
40
41
    /**
42
     * @param $id
43
     * @return mixed|string
44
     */
45
    public function get_pagenum_link($id)
0 ignored issues
show
Coding Style introduced by
Method name "DLpaginateReversed::get_pagenum_link" is not in camel caps format
Loading history...
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
46
    {
47
        $flag = (strpos($this->target, '?') === false);
48
        $value = $this->getPageQuery($id);
49
        if ($flag && !empty($this->urlF)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
50
            $out = str_replace($this->urlF, $value, $this->target);
51
        } else {
52
            $out = $this->target;
53
            if ($id > 0 && $id < $this->total_pages) {
54
                $out .= ($flag ? "?" : "&") . $this->parameterName . "=" . $value;
55
            }
56
        }
57
58
        return $out;
59
    }
60
}
61