Completed
Branch EDTR/master (f9130a)
by
unknown
46:59 queued 38:09
created

InputBase::fields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\services\graphql\inputs;
4
5
use EventEspresso\core\services\graphql\fields\GraphQLField;
6
use EventEspresso\core\services\graphql\fields\GraphQLFieldInterface;
7
8
/**
9
 * Class InputBase
10
 * Description
11
 *
12
 * @package EventEspresso\core\services\graphql
13
 * @author  Manzoor Wani
14
 * @since   $VID:$
15
 */
16
abstract class InputBase implements InputInterface
17
{
18
19
    /**
20
     * @var string $name
21
     */
22
    protected $name = '';
23
24
    /**
25
     * @var string $description
26
     */
27
    protected $description = '';
28
29
    /**
30
     * @var \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] $fields
31
     */
32
    protected $fields = [];
33
34
    /**
35
     * InputBase constructor.
36
     */
37
    public function __construct()
38
    {
39
        $this->setFields($this->getFields());
40
    }
41
42
43
    /**
44
     * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[]
45
     * @since $VID:$
46
     */
47
    abstract protected function getFields();
48
49
50
    /**
51
     * @return string
52
     */
53
    public function name()
54
    {
55
        return $this->name;
56
    }
57
58
59
    /**
60
     * @param string $name
61
     */
62
    protected function setName($name)
63
    {
64
        $this->name = $name;
65
    }
66
67
68
    /**
69
     * @return string
70
     */
71
    public function description()
72
    {
73
        return $this->description;
74
    }
75
76
77
    /**
78
     * @param string $description
79
     */
80
    protected function setDescription($description)
81
    {
82
        $this->description = $description;
83
    }
84
85
86
    /**
87
     * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[]
88
     * @since $VID:$
89
     */
90
    public function fields()
91
    {
92
        return (array) $this->fields;
93
    }
94
95
96
    /**
97
     * @param \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] $fields
98
     */
99
    protected function setFields(array $fields)
100
    {
101
        foreach ($fields as $field) {
102
            if ($field instanceof GraphQLField) {
103
                $this->fields[] = $field;
104
            }
105
        }
106
    }
107
}
108