Completed
Push — master ( d7fcc6...aeb790 )
by Christoffer
02:03
created

TypesTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypesAsArray() 0 5 1
A getTypes() 0 3 1
A setTypes() 0 4 1
A hasTypes() 0 3 1
1
<?php
2
3
namespace Digia\GraphQL\Language\Node;
4
5
use Digia\GraphQL\Util\SerializationInterface;
6
7
trait TypesTrait
8
{
9
10
    /**
11
     * @var NamedTypeNode[]
12
     */
13
    protected $types;
14
15
    /**
16
     * @return bool
17
     */
18
    public function hasTypes(): bool
19
    {
20
        return !empty($this->types);
21
    }
22
23
    /**
24
     * @return NamedTypeNode[]
25
     */
26
    public function getTypes(): array
27
    {
28
        return $this->types;
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    public function getTypesAsArray(): array
35
    {
36
        return array_map(function (SerializationInterface $node) {
37
            return $node->toArray();
38
        }, $this->types);
39
    }
40
41
    /**
42
     * @param array|NamedTypeNode[] $types
43
     * @return $this
44
     */
45
    public function setTypes(array $types)
46
    {
47
        $this->types = $types;
48
        return $this;
49
    }
50
}
51