Completed
Pull Request — master (#4)
by Arthur
03:44
created

Type::setInterfaces()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Arthem\GraphQLMapper\Mapping;
4
5
class Type extends FieldContainer
6
{
7
    /**
8
     * @var array
9
     */
10
    private $interfaces = [];
11
12
    /**
13
     * @var array
14
     */
15
    private $values;
16
17
    /**
18
     * @return array
19
     */
20
    public function getInterfaces()
21
    {
22
        return $this->interfaces;
23
    }
24
25
    /**
26
     * @param array $interfaces
27
     * @return $this
28
     */
29
    public function setInterfaces(array $interfaces)
30
    {
31
        $this->interfaces = $interfaces;
32
33
        return $this;
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function getValues()
40
    {
41
        return $this->values;
42
    }
43
44
    /**
45
     * @param array $values
46
     * @return $this
47
     */
48
    public function setValues(array $values)
49
    {
50
        $this->values = $values;
51
        $this->setInternalType('EnumType');
52
53
        return $this;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function toMapping()
60
    {
61
        $mapping = parent::toMapping();
62
63
        if ($this->interfaces) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->interfaces of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
64
            $mapping['interfaces'] = $this->interfaces;
65
        }
66
        if ($this->values) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->values of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
67
            $mapping['values'] = $this->values;
68
        }
69
70
        return $mapping;
71
    }
72
}
73