Completed
Push — master ( 1fe708...6360f1 )
by Arnaud
16s queued 12s
created

ORMDataSource   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
eloc 19
c 1
b 1
f 0
dl 0
loc 53
ccs 10
cts 20
cp 0.5
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
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Bridge\Doctrine\DataSource;
6
7
use Doctrine\ORM\QueryBuilder;
8
use LAG\AdminBundle\DataProvider\DataSourceInterface;
9
10
class ORMDataSource implements DataSourceInterface
11
{
12
    private QueryBuilder $data;
13
    private bool $pagination;
14
    private int $page;
15
    private int $maxPerPage;
16
    private array $orderBy;
17
    private array $filters;
18
19 6
    public function __construct(
20
        QueryBuilder $data,
21
        bool $pagination,
22
        int $page = 1,
23
        int $maxPerPage = 25,
24
        array $orderBy = [],
25
        array $filters = []
26
    ) {
27 6
        $this->data = $data;
28 6
        $this->pagination = $pagination;
29 6
        $this->page = $page;
30 6
        $this->maxPerPage = $maxPerPage;
31 6
        $this->orderBy = $orderBy;
32 6
        $this->filters = $filters;
33 6
    }
34
35 6
    public function getData(): QueryBuilder
36
    {
37 6
        return $this->data;
38
    }
39
40
    public function isPaginated(): bool
41
    {
42
        return $this->pagination;
43
    }
44
45
    public function getPage(): int
46
    {
47
        return $this->page;
48
    }
49
50
    public function getMaxPerPage(): int
51
    {
52
        return $this->maxPerPage;
53
    }
54
55
    public function getOrderBy(): array
56
    {
57
        return $this->orderBy;
58
    }
59
60
    public function getFilters(): array
61
    {
62
        return $this->filters;
63
    }
64
}
65