Passed
Pull Request — master (#49)
by
unknown
14:54
created

PaginationSet::getPageUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Pagination;
4
5
use Closure;
6
use Yiisoft\Data\Paginator\OffsetPaginator;
7
8
/**
9
 * @deprecated Should be replaced to a Pagination Widget
10
 */
11
class PaginationSet
12
{
13
    private OffsetPaginator $paginator;
14
    private Closure $pageUrlGenerator;
15
16
    public function __construct(
17
        OffsetPaginator $paginator,
18
        Closure $pageUrlGenerator
19
    ) {
20
        $this->paginator = $paginator;
21
        $this->pageUrlGenerator = $pageUrlGenerator;
22
    }
23
24
    public function getPageUrl(int $page): string
25
    {
26
        return ($this->pageUrlGenerator)($page);
27
    }
28
29
    public function getPaginator(): OffsetPaginator
30
    {
31
        return $this->paginator;
32
    }
33
34
    public function needToPaginate(): bool
35
    {
36
        return $this->getPaginator()->isRequired();
37
    }
38
}
39