Completed
Pull Request — master (#13)
by Rafael
06:46
created

UnionDefinition   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 59
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getResolver() 0 3 1
A addType() 0 3 1
A removeType() 0 3 1
A getTypes() 0 3 1
A setResolver() 0 5 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Definition;
12
13
use Ynlo\GraphQLBundle\Definition\Traits\ClassAwareDefinitionTrait;
14
use Ynlo\GraphQLBundle\Definition\Traits\DefinitionTrait;
15
16
/**
17
 * UnionDefinition
18
 */
19
class UnionDefinition implements
20
    DefinitionInterface,
21
    ClassAwareDefinitionInterface
22
{
23
    use DefinitionTrait;
24
    use ClassAwareDefinitionTrait;
25
26
    /**
27
     * @var UnionTypeDefinition[]
28
     */
29
    protected $types = [];
30
31
    /**
32
     * @var string
33
     */
34
    protected $resolver;
35
36
    /**
37
     * @return UnionTypeDefinition[]
38
     */
39
    public function getTypes(): array
40
    {
41
        return $this->types;
42
    }
43
44
    /**
45
     * @param UnionTypeDefinition $type
46
     */
47
    public function addType(UnionTypeDefinition $type)
48
    {
49
        $this->types[$type->getType()] = $type;
50
    }
51
52
    /**
53
     * @param string $type
54
     */
55
    public function removeType(string $type)
56
    {
57
        unset($this->types[$type]);
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getResolver(): string
64
    {
65
        return $this->resolver;
66
    }
67
68
    /**
69
     * @param string $resolver
70
     *
71
     * @return UnionDefinition
72
     */
73
    public function setResolver(string $resolver): UnionDefinition
74
    {
75
        $this->resolver = $resolver;
76
77
        return $this;
78
    }
79
}
80