12
12
class Type extends Fluent implements TypeConvertible
13
13
{
14
14
protected static $ instances = [];
15
-
15
+
16
16
protected $ inputObject = false ;
17
17
protected $ enumObject = false ;
18
-
18
+
19
19
public function attributes ()
20
20
{
21
21
return [];
22
22
}
23
-
23
+
24
24
public function fields ()
25
25
{
26
26
return [];
27
27
}
28
-
28
+
29
29
public function interfaces ()
30
30
{
31
31
return [];
32
32
}
33
-
33
+
34
34
protected function getFieldResolver ($ name , $ field )
35
35
{
36
36
$ resolveMethod = 'resolve ' .studly_case ($ name ).'Field ' ;
@@ -43,10 +43,10 @@ protected function getFieldResolver($name, $field)
43
43
return call_user_func_array ($ resolver , $ args );
44
44
};
45
45
}
46
-
46
+
47
47
return null ;
48
48
}
49
-
49
+
50
50
public function getFields ()
51
51
{
52
52
$ fields = $ this ->fields ();
@@ -57,11 +57,9 @@ public function getFields()
57
57
$ field ->name = $ name ;
58
58
$ allFields [$ name ] = $ field ->toArray ();
59
59
} else {
60
-
61
60
$ resolver = $ this ->getFieldResolver ($ name , $ field );
62
61
63
62
if (isset ($ field ['class ' ])) {
64
-
65
63
$ field = $ field ['class ' ];
66
64
67
65
if (is_string ($ field )) {
@@ -79,7 +77,7 @@ public function getFields()
79
77
$ allFields [$ name ] = $ field ;
80
78
}
81
79
}
82
-
80
+
83
81
return $ allFields ;
84
82
}
85
83
@@ -92,17 +90,17 @@ public function getAttributes()
92
90
{
93
91
$ attributes = $ this ->attributes ();
94
92
$ interfaces = $ this ->interfaces ();
95
-
93
+
96
94
$ attributes = array_merge ($ this ->attributes , [
97
95
'fields ' => function () {
98
96
return $ this ->getFields ();
99
97
}
100
98
], $ attributes );
101
-
99
+
102
100
if (sizeof ($ interfaces )) {
103
101
$ attributes ['interfaces ' ] = $ interfaces ;
104
102
}
105
-
103
+
106
104
return $ attributes ;
107
105
}
108
106
@@ -115,7 +113,7 @@ public function toArray()
115
113
{
116
114
return $ this ->getAttributes ();
117
115
}
118
-
116
+
119
117
public function toType ()
120
118
{
121
119
if ($ this ->inputObject ) {
0 commit comments