PaginationInputType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 24
c 2
b 0
f 0
dl 0
loc 39
ccs 0
cts 32
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 24 1
A build() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Api\Input;
6
7
use GraphQL\Doctrine\Types;
8
use GraphQL\Type\Definition\InputObjectType;
9
10
final class PaginationInputType extends InputObjectType
11
{
12
    public static function build(Types $types): array
13
    {
14
        return [
15
            'name' => 'pagination',
16
            'type' => $types->get(self::class),
17
            'defaultValue' => [
18
                'offset' => null,
19
                'pageIndex' => 0,
20
                'pageSize' => 50,
21
            ],
22
        ];
23
    }
24
25
    public function __construct()
26
    {
27
        $config = [
28
            'description' => 'Describe what page we want',
29
            'fields' => fn (): array => [
30
                'offset' => [
31
                    'type' => self::int(),
32
                    'defaultValue' => null,
33
                    'description' => 'The zero-based index of first item of the page. If given a value greater than zero, then `pageIndex` is ignored.',
34
                ],
35
                'pageIndex' => [
36
                    'type' => self::int(),
37
                    'defaultValue' => 0,
38
                    'description' => 'The zero-based index of the page. If given negative value, then fallback to 0.',
39
                ],
40
                'pageSize' => [
41
                    'type' => self::int(),
42
                    'defaultValue' => 50,
43
                    'description' => 'Number of items to display on a page. If given negative value, then fallback to 0.',
44
                ],
45
            ],
46
        ];
47
48
        parent::__construct($config);
49
    }
50
}
51