PaginatorTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setPaginator() 0 7 1
A getSortableFields() 0 3 1
A getFieldsAssociations() 0 3 1
A getFilterableFields() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Mgid\PaginationBundle\DependencyInjection;
4
5
use Mgid\Component\Pagination\Paginator;
6
7
trait PaginatorTrait
8
{
9
    protected Paginator $paginator;
10
11
    /**
12
     * @required
13
     *
14
     * @param Paginator $paginator
15
     */
16
    public function setPaginator(Paginator $paginator): void
17
    {
18
        $this->paginator = $paginator;
19
20
        $this->paginator->getMapping()->setAssociations($this->getFieldsAssociations());
21
        $this->paginator->getMapping()->getConstraint()->setOrders($this->getSortableFields());
22
        $this->paginator->getMapping()->getConstraint()->setFilters($this->getFilterableFields());
23
    }
24
25
    /**
26
     * @return string[]
27
     */
28
    protected function getSortableFields(): array
29
    {
30
        return [];
31
    }
32
33
    /**
34
     * @return string[]
35
     */
36
    protected function getFilterableFields(): array
37
    {
38
        return [];
39
    }
40
41
    /**
42
     * @return array<string,string>
43
     */
44
    protected function getFieldsAssociations(): array
45
    {
46
        return [];
47
    }
48
}
49