Passed
Push — master ( 8ce43b...977552 )
by Adrien
13:23
created

AbstractSorting::getSortedQueryResult()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApplicationTest\Api\Input\Sorting;
6
7
use PHPUnit\Framework\TestCase;
8
9
class AbstractSorting extends TestCase
10
{
11
    protected function getSortedQueryResult(string $class, string $field): array
12
    {
13
        $sorting = $this->getSorting($field);
14
        $qb = _types()->createFilteredQueryBuilder($class, [], $sorting);
15
16
        $result = [];
17
        foreach ($qb->getQuery()->getResult() as $item) {
18
            $result[] = $item->getId();
19
        }
20
21
        return $result;
22
    }
23
24
    private function getSorting(string $field): array
25
    {
26
        return [
27
            [
28
                'field' => $field,
29
                'order' => 'DESC',
30
            ],
31
            [
32
                'field' => 'id',
33
                'order' => 'ASC',
34
            ],
35
        ];
36
    }
37
}
38