@@ -22,6 +22,14 @@ class Import
2222 protected $ DEFAULT_API_JSON_PATH = './config/api.json ' ;
2323 protected $ DEFAULT_SOURCE_JSON_PATH = './config/postman.json ' ;
2424
25+ /**
26+ * Import constructor.
27+ *
28+ * @param string $filePath Path containing source (Postman generated) json file
29+ * @param array $options
30+ *
31+ * @throws \ReflectionException
32+ */
2533 public function __construct ($ filePath = '' , $ options = [])
2634 {
2735
@@ -50,6 +58,11 @@ public function __construct($filePath = '', $options = [])
5058 $ this ->options = $ options ;
5159 }
5260
61+ /**
62+ * @param $filePath Path containing source (Postman generated) json file
63+ *
64+ * @return array
65+ */
5366 protected function importFromJson ($ filePath )
5467 {
5568
@@ -111,6 +124,11 @@ protected function importFromJson($filePath)
111124 return $ data ;
112125 }
113126
127+ /**
128+ * @param array $request
129+ *
130+ * @return array
131+ */
114132 protected function parseOperation ($ request = [])
115133 {
116134 $ meta = [$ request ];
@@ -128,6 +146,13 @@ protected function parseOperation($request = [])
128146
129147 }
130148
149+ /**
150+ * @param array $paths
151+ * @param string $bodyRaw
152+ * @param array $meta
153+ *
154+ * @return array
155+ */
131156 protected function parseParams ($ paths = [], $ bodyRaw = '' , $ meta = [])
132157 {
133158 $ params = [];
@@ -164,11 +189,22 @@ protected function parseParams($paths = [], $bodyRaw = '', $meta = [])
164189
165190 }
166191
192+ /**
193+ * @param $url
194+ * @param array $meta
195+ *
196+ * @return string
197+ */
167198 protected function parseUri ($ url , $ meta = [])
168199 {
169200 return implode ('/ ' , array_slice ($ url ['path ' ], 2 ));
170201 }
171202
203+ /**
204+ * @param $api
205+ *
206+ * @return string
207+ */
172208 protected function parseApiName ($ api )
173209 {
174210
@@ -207,6 +243,13 @@ protected function parseApiName($api)
207243
208244 }
209245
246+ /**
247+ * @param $operation
248+ * @param array $api
249+ * @param string $method
250+ *
251+ * @return array
252+ */
210253 protected function generateDocs ($ operation , $ api = [], $ method = '' ) {
211254
212255// $baseUri = $this->clientOptions['base_url'] ?: '';
@@ -251,6 +294,11 @@ protected function generateMethod($apiName, $operation = [], $api = []) {
251294
252295 }
253296
297+ /**
298+ * @param string $string
299+ *
300+ * @return string
301+ */
254302 protected function sluggify ($ string = '' )
255303 {
256304 if (!empty ($ string )) {
@@ -261,22 +309,36 @@ protected function sluggify($string = '')
261309 return $ string ;
262310 }
263311
264-
312+ /**
313+ * @return array
314+ */
265315 public function getData ()
266316 {
267317 return $ this ->data ;
268318 }
269319
320+ /**
321+ * @return array
322+ */
270323 public function getDocs ()
271324 {
272325 return $ this ->docsData ;
273326 }
274327
328+ /**
329+ * @return array
330+ */
275331 public function getMethods ()
276332 {
277333 return $ this ->methodData ;
278334 }
279335
336+ /**
337+ * @param string $path
338+ * @param array $options
339+ *
340+ * @return bool|int
341+ */
280342 public function writeData ($ path = '' , $ options = [])
281343 {
282344 if (empty ($ path )) {
@@ -300,7 +362,11 @@ public function writeData($path = '', $options = [])
300362 return file_put_contents ($ path , $ json );
301363 }
302364
303-
365+ /**
366+ * @param string $path
367+ *
368+ * @return bool|int
369+ */
304370 protected function writeMDDocs ($ path = '' ) {
305371
306372 if (empty ($ path )) {
@@ -347,6 +413,11 @@ protected function writeMDDocs($path = '') {
347413 return file_put_contents ($ path , $ mdText );
348414 }
349415
416+ /**
417+ * @param string $path
418+ *
419+ * @return bool|int
420+ */
350421 protected function writeMethods ($ path = '' ) {
351422
352423 if (empty ($ path )) {
@@ -367,9 +438,17 @@ protected function writeMethods($path = '') {
367438 return file_put_contents ($ path , $ methodText );
368439 }
369440
441+ /**
442+ * @return string
443+ * @throws \ReflectionException
444+ */
370445 private function getChildDir () {
371446 return dirname ((new \ReflectionClass (static ::class))->getFileName ());
372447 }
448+
449+ /**
450+ * @return string
451+ */
373452 private function getDir () {
374453 return __DIR__ ;
375454 }
0 commit comments