BetweenInputObjectType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 23
rs 9.7
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