Completed
Pull Request — master (#2)
by Adrien
02:16
created

Field   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 39
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 14 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Doctrine\Annotation;
6
7
use GraphQL\Type\Definition\Type;
8
9
/**
10
 * Annotation used to override values for an output field in GraphQL.
11
 *
12
 * All values are optional and should only be used to override
13
 * what is declared by the original method.
14
 *
15
 * @Annotation
16
 * @Target({"METHOD"})
17
 */
18
class Field
19
{
20
    /**
21
     * @var string
22
     */
23
    public $name;
24
25
    /**
26
     * FQCN of PHP class implementing the GraphQL type
27
     *
28
     * @var string
29
     */
30
    public $type;
31
32
    /**
33
     * @var string
34
     */
35
    public $description;
36
37
    /**
38
     * @var array<GraphQL\Doctrine\Annotation\Argument>
39
     */
40
    public $args = [];
41
42
    public function toArray(): array
43
    {
44
        $args = [];
45
        foreach ($this->args as $arg) {
46
            $args[] = $arg->toArray();
47
        }
48
49
        return [
50
            'name' => $this->name,
51
            'type' => $this->type,
52
            'description' => $this->description,
53
            'args' => $args,
54
        ];
55
    }
56
}
57