Completed
Pull Request — master (#63)
by David
02:48
created

Factory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getName() 0 3 1
1
<?php
2
3
4
namespace TheCodingMachine\GraphQL\Controllers\Annotations;
5
6
/**
7
 * Factories are methods used to declare GraphQL input types.
8
 *
9
 * @Annotation
10
 * @Target({"METHOD"})
11
 * @Attributes({
12
 *   @Attribute("name", type = "string")
13
 * })
14
 */
15
class Factory
16
{
17
    /**
18
     * @var string|null
19
     */
20
    private $name;
21
22
    /**
23
     * @param mixed[] $attributes
24
     */
25
    public function __construct(array $attributes = [])
26
    {
27
        $this->name = $attributes['name'] ?? null;
28
    }
29
30
    /**
31
     * Returns the name of the GraphQL input type.
32
     * If not specified, the name of the method should be used instead.
33
     *
34
     * @return null|string
35
     */
36
    public function getName(): ?string
37
    {
38
        return $this->name;
39
    }
40
}
41