DLpaginateReversed::renderItemTPL()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 1
b 1
f 0
cc 1
nc 1
nop 2
crap 2
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