Passed
Pull Request — main (#117)
by Tom
02:58
created

BetweenInputObjectType   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiSkeletons\Doctrine\GraphQL\Criteria\Type;
6
7
use ApiSkeletons\Doctrine\GraphQL\Criteria\Filters as FiltersDef;
8
use GraphQL\Type\Definition\InputObjectField;
9
use GraphQL\Type\Definition\InputObjectType;
10
use GraphQL\Type\Definition\ListOfType;
11
use GraphQL\Type\Definition\ScalarType;
12
13
class BetweenInputObjectType extends InputObjectType
14
{
15
    public function __construct(string $typeName, string $fieldName, ScalarType|ListOfType $type)
16
    {
17
        $fields = [
18
            'from' => new InputObjectField([
19
                'name'        => 'from',
20
                'type'        => $type,
21
                'description' => 'Low value of between',
22
            ]),
23
            'to' => new InputObjectField([
24
                'name'        => 'to',
25
                'type'        => $type,
26
                'description' => 'High value of between',
27
            ]),
28
        ];
29
30
        parent::__construct([
31
            'name' => $typeName
32
                . '_' . $fieldName
33
                . '_filters_'
34
                . FiltersDef::BETWEEN
35
                . '_fields',
36
            'description' => 'Between `from` and `to`',
37
            'fields' => static fn () => $fields,
38
        ]);
39
    }
40
}
41