Passed
Push — master ( 3b66e1...fb7c7d )
by Andrey
58s queued 12s
created

AbstractAnonymousObjectField::__construct()   B

Complexity

Conditions 9
Paths 32

Size

Total Lines 28
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 90

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 9
eloc 13
c 1
b 0
f 0
nc 32
nop 4
dl 0
loc 28
ccs 0
cts 14
cp 0
crap 90
rs 8.0555
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 $resolve;
14
    protected readonly mixed $complexity;
15
16
    public function __construct(
17
        string $name,
18
        array $field,
19
        ?callable $resolve = null,
20
        ?callable $complexity = null,
21
    ) {
22
        $this->name = $name;
23
        $this->type = $field['type'];
24
        $this->typeMode = $field['typeMode'] ?? 0;
25
26
        if (isset($field['description']) && is_string($field['description'])) {
27
            $this->description = $field['description'];
28
        }
29
30
        if (isset($field['deprecationReason']) && is_string($field['deprecationReason'])) {
31
            $this->deprecationReason = $field['deprecationReason'];
32
        }
33
34
        if (isset($field['arguments']) && is_iterable($field['arguments'])) {
35
            $this->arguments = $field['arguments'];
36
        }
37
38
        if (null !== $resolve) {
39
            $this->resolve = $resolve;
0 ignored issues
show
Bug introduced by
The property resolve is declared read-only in Andi\GraphQL\Field\AbstractAnonymousObjectField.
Loading history...
40
        }
41
42
        if (null !== $complexity) {
43
            $this->complexity = $complexity;
0 ignored issues
show
Bug introduced by
The property complexity is declared read-only in Andi\GraphQL\Field\AbstractAnonymousObjectField.
Loading history...
44
        }
45
    }
46
}
47