| Conditions | 1 |
| Paths | 1 |
| Total Lines | 38 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 34 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 1 | public static function build(): iterable |
|
| 18 | { |
||
| 19 | 1 | yield 'purchases' => fn () => [ |
|
| 20 | 1 | 'type' => Type::nonNull(_types()->get('OrderLinePagination')), |
|
| 21 | 1 | 'description' => 'Get purchases of a given user', |
|
| 22 | 1 | 'args' => [ |
|
| 23 | 1 | [ |
|
| 24 | 1 | 'name' => 'filter', |
|
| 25 | 1 | 'type' => _types()->getFilter(Product::class), |
|
| 26 | 1 | ], |
|
| 27 | 1 | [ |
|
| 28 | 1 | 'name' => 'sorting', |
|
| 29 | 1 | 'type' => _types()->getSorting(Product::class), |
|
| 30 | 1 | 'defaultValue' => [ |
|
| 31 | 1 | [ |
|
| 32 | 1 | 'field' => 'releaseDate', |
|
| 33 | 1 | 'order' => 'ASC', |
|
| 34 | 1 | ], |
|
| 35 | 1 | [ |
|
| 36 | 1 | 'field' => 'code', |
|
| 37 | 1 | 'order' => 'DESC', |
|
| 38 | 1 | ], |
|
| 39 | 1 | [ |
|
| 40 | 1 | 'field' => 'id', |
|
| 41 | 1 | 'order' => 'ASC', |
|
| 42 | 1 | ], |
|
| 43 | 1 | ], |
|
| 44 | 1 | ], |
|
| 45 | 1 | PaginationInputType::build(_types()), |
|
| 46 | 1 | ], |
|
| 47 | 1 | 'resolve' => function ($root, array $args): array { |
|
| 48 | /** @var OrderLineRepository $orderLineRepository */ |
||
| 49 | 1 | $orderLineRepository = _em()->getRepository(OrderLine::class); |
|
| 50 | 1 | $qb = $orderLineRepository->createPurchaseQueryBuilder($args['filter'] ?? [], $args['sorting'] ?? []); |
|
| 51 | |||
| 52 | 1 | $items = Helper::paginate($args['pagination'], $qb); |
|
| 53 | |||
| 54 | 1 | return $items; |
|
| 55 | 1 | }, |
|
| 59 |