Connection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 3
dl 0
loc 17
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiSkeletons\Doctrine\GraphQL\Type;
6
7
use ApiSkeletons\Doctrine\GraphQL\AbstractContainer;
8
use ApiSkeletons\Doctrine\GraphQL\Buildable;
9
use GraphQL\Type\Definition\ObjectType;
10
use GraphQL\Type\Definition\Type;
11
12
use function assert;
13
14
/**
15
 * This type is built within the TypeManager
16
 */
17
class Connection extends ObjectType implements
18
    Buildable
19
{
20
    /** @param mixed[] $params */
21
    public function __construct(AbstractContainer $container, string $typeName, array $params)
22
    {
23
        assert($params[0] instanceof ObjectType);
24
        $objectType = $params[0];
25
26
        $configuration = [
27
            'name' => $typeName,
28
            'description' => 'Connection for ' . $typeName,
29
            'fields' => [
30
                'edges' => Type::listOf($container
31
                    ->build(Node::class, $typeName . '_Node', $objectType)),
32
                'totalCount' => Type::nonNull(Type::int()),
33
                'pageInfo' => $container->get('PageInfo'),
34
            ],
35
        ];
36
37
        parent::__construct($configuration);
38
    }
39
}
40