Passed
Pull Request — master (#259)
by Arnaud
08:22
created

ORMDataSource   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
eloc 19
c 1
b 1
f 0
dl 0
loc 53
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilters() 0 3 1
A getMaxPerPage() 0 3 1
A getData() 0 3 1
A isPaginated() 0 3 1
A getPage() 0 3 1
A __construct() 0 14 1
A getOrderBy() 0 3 1
1
<?php
2
3
namespace LAG\AdminBundle\Bridge\Doctrine\DataSource;
4
5
use Doctrine\ORM\QueryBuilder;
6
use LAG\AdminBundle\DataProvider\DataSourceInterface;
7
8
class ORMDataSource implements DataSourceInterface
9
{
10
    private QueryBuilder $data;
11
    private bool $pagination;
12
    private int $page;
13
    private int $maxPerPage;
14
    private array $orderBy;
15
    private array $filters;
16
17
    public function __construct(
18
        QueryBuilder $data,
19
        bool $pagination,
20
        int $page = 1,
21
        int $maxPerPage = 25,
22
        array $orderBy = [],
23
        array $filters = []
24
    ) {
25
        $this->data = $data;
26
        $this->pagination = $pagination;
27
        $this->page = $page;
28
        $this->maxPerPage = $maxPerPage;
29
        $this->orderBy = $orderBy;
30
        $this->filters = $filters;
31
    }
32
33
    public function getData(): QueryBuilder
34
    {
35
        return $this->data;
36
    }
37
38
    public function isPaginated(): bool
39
    {
40
        return $this->pagination;
41
    }
42
43
    public function getPage(): int
44
    {
45
        return $this->page;
46
    }
47
48
    public function getMaxPerPage(): int
49
    {
50
        return $this->maxPerPage;
51
    }
52
53
    public function getOrderBy(): array
54
    {
55
        return $this->orderBy;
56
    }
57
58
    public function getFilters(): array
59
    {
60
        return $this->filters;
61
    }
62
}
63