Passed
Push — master ( 898411...5b804b )
by Andrey
56s queued 13s
created

AbstractAnonymousObjectField   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 28 9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Field;
6
7
/**
8
 * @internal
9
 * @psalm-internal Andi\GraphQL
10
 */
11
abstract class AbstractAnonymousObjectField extends AbstractObjectField
12
{
13
    protected readonly mixed $resolveFn;
14
    protected readonly mixed $complexityFn;
15
16 14
    public function __construct(
17
        string $name,
18
        array $field,
19
        ?callable $resolve = null,
20
        ?callable $complexity = null,
21
    ) {
22 14
        $this->name = $name;
23 14
        $this->type = $field['type'];
24 14
        $this->mode = $field['mode'] ?? 0;
25
26 14
        if (isset($field['description']) && is_string($field['description'])) {
27 1
            $this->description = $field['description'];
28
        }
29
30 14
        if (isset($field['deprecationReason']) && is_string($field['deprecationReason'])) {
31 1
            $this->deprecationReason = $field['deprecationReason'];
32
        }
33
34 14
        if (isset($field['arguments']) && is_iterable($field['arguments'])) {
35 1
            $this->arguments = $field['arguments'];
36
        }
37
38 14
        if (null !== $resolve) {
39 8
            $this->resolveFn = $resolve;
0 ignored issues
show
Bug introduced by
The property resolveFn is declared read-only in Andi\GraphQL\Field\AbstractAnonymousObjectField.
Loading history...
40
        }
41
42 14
        if (null !== $complexity) {
43 8
            $this->complexityFn = $complexity;
0 ignored issues
show
Bug introduced by
The property complexityFn is declared read-only in Andi\GraphQL\Field\AbstractAnonymousObjectField.
Loading history...
44
        }
45
    }
46
}
47