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

PaginationSet   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A needToPaginate() 0 3 1
A getPaginator() 0 3 1
A __construct() 0 6 1
A getPageUrl() 0 3 1
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