File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,60 @@ public function getReturn(array $method, array $spec): string
9292 return 'Promise<{}> ' ;
9393 }
9494
95+ /**
96+ * @param array $param
97+ * @return string
98+ */
99+ public function getParamExample (array $ param ): string
100+ {
101+ $ type = $ param ['type ' ] ?? '' ;
102+ $ example = $ param ['example ' ] ?? '' ;
103+
104+ $ output = '' ;
105+
106+ if (empty ($ example ) && $ example !== 0 && $ example !== false ) {
107+ switch ($ type ) {
108+ case self ::TYPE_NUMBER :
109+ case self ::TYPE_INTEGER :
110+ case self ::TYPE_BOOLEAN :
111+ $ output .= 'null ' ;
112+ break ;
113+ case self ::TYPE_STRING :
114+ $ output .= "'' " ;
115+ break ;
116+ case self ::TYPE_ARRAY :
117+ $ output .= '[] ' ;
118+ break ;
119+ case self ::TYPE_OBJECT :
120+ $ output .= '{} ' ;
121+ break ;
122+ case self ::TYPE_FILE :
123+ $ output .= "InputFile.fromPath('/path/to/file', 'filename') " ;
124+ break ;
125+ }
126+ } else {
127+ switch ($ type ) {
128+ case self ::TYPE_NUMBER :
129+ case self ::TYPE_INTEGER :
130+ case self ::TYPE_ARRAY :
131+ case self ::TYPE_OBJECT :
132+ $ output .= $ example ;
133+ break ;
134+ case self ::TYPE_BOOLEAN :
135+ $ output .= ($ example ) ? 'true ' : 'false ' ;
136+ break ;
137+ case self ::TYPE_STRING :
138+ $ output .= "' {$ example }' " ;
139+ break ;
140+ case self ::TYPE_FILE :
141+ $ output .= "InputFile.fromPath('/path/to/file', 'filename') " ;
142+ break ;
143+ }
144+ }
145+
146+ return $ output ;
147+ }
148+
95149 /**
96150 * @return array
97151 */
You can’t perform that action at this time.
0 commit comments