File tree 3 files changed +27
-21
lines changed
3 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 22
22
23
23
*
24
24
<?php foreach ($ model ->dbAttributes () as $ attribute ): ?>
25
- * @property <?= $ attribute ->getFormattedDescription () ?>
25
+ * @property <?= $ attribute ->getAttributeAnnotation () ?>
26
26
27
27
<?php endforeach ; ?>
28
28
*
Original file line number Diff line number Diff line change @@ -295,11 +295,27 @@ public function getMinLength():?int
295
295
return $ this ->limits ['minLength ' ];
296
296
}
297
297
298
- public function getFormattedDescription ():string
298
+ public function getAttributeAnnotation ():string
299
299
{
300
- $ comment = $ this ->columnName .' ' .$ this ->description ;
301
- $ type = $ this ->phpType ;
302
- return $ type .' $ ' .str_replace ("\n" , "\n * " , rtrim ($ comment ));
300
+ $ annotation = $ this ->phpType . ' $ ' . $ this ->columnName ;
301
+ if (!empty ($ this ->description )) {
302
+ $ annotation .= self ::getFormattedDescription ($ this ->description );
303
+ }
304
+ return $ annotation ;
305
+ }
306
+
307
+ /**
308
+ * @param $description
309
+ * @return string
310
+ * @noinspection PhpParamsInspection
311
+ */
312
+ public static function getFormattedDescription ($ description )
313
+ {
314
+ $ descriptionArr = explode ("\n" , trim ($ description ));
315
+ $ descriptionArr = array_map (function ($ item ) {
316
+ return $ item !== '' ? ' ' . $ item : $ item ;
317
+ }, $ descriptionArr );
318
+ return implode ("\n * " , $ descriptionArr );
303
319
}
304
320
305
321
public function toColumnSchema ():ColumnSchema
Original file line number Diff line number Diff line change @@ -234,25 +234,15 @@ private function getScenariosByOpenapiSchema(): array
234
234
return $ scenarios ;
235
235
}
236
236
237
- public function getModelClassDescription_ ()
238
- {
239
- return !empty ($ this ->description ) ?
240
- str_replace ("\n" , "\n * " , ' ' . trim ($ this ->description ))
241
- : ' This is the model class for table " ' .$ this ->tableName .'". ' ;
242
- }
243
-
244
- /** @noinspection PhpParamsInspection */
245
- public function getModelClassDescription ()
237
+ /**
238
+ * @return string
239
+ */
240
+ public function getModelClassDescription (): string
246
241
{
247
242
if (empty ($ this ->description )) {
248
243
return ' This is the model class for table " ' .$ this ->tableName .'". ' ;
249
244
}
250
-
251
- $ descriptionArr = explode ("\n" , $ this ->description );
252
- $ descriptionArr = array_map ('trim ' , $ descriptionArr );
253
- $ descriptionArr = array_map (function ($ item ) {
254
- return $ item !== '' ? ' ' . $ item : $ item ;
255
- }, $ descriptionArr );
256
- return implode ("\n * " , $ descriptionArr );
245
+ return Attribute::getFormattedDescription ($ this ->description );
257
246
}
247
+
258
248
}
You can’t perform that action at this time.
0 commit comments