44
55use Carbon \Carbon ;
66use CodebarAg \DocuWare \DTO \TableRow ;
7+ use Illuminate \Support \Arr ;
78use Illuminate \Support \Collection ;
89use Illuminate \Support \Str ;
910
@@ -23,21 +24,21 @@ public static function field(
2324 ?array $ field ,
2425 null |int |float |Carbon |string |Collection $ default = null ,
2526 ): null |int |float |Carbon |string |Collection {
26- if (! $ field ) {
27+ if (! $ field || $ field [ ' IsNull ' ] ) {
2728 return $ default ;
2829 }
2930
30- if ($ field[ ' IsNull ' ]) {
31- return $ default ;
32- }
33-
34- return match ( $ field [ ' ItemElementName ' ]) {
35- 'Int ' => (int ) $ field [ ' Item ' ] ,
36- 'Decimal ' => (float ) $ field [ ' Item ' ] ,
37- 'Date ' , 'DateTime ' => self ::date ($ field [ ' Item ' ] ),
38- 'Keywords ' => implode ( ' , ' , $ field [ ' Item ' ][ ' Keyword ' ] ),
39- 'Table ' => self ::table ($ field [ ' Item ' ] ),
40- default => ( string ) $ field [ ' Item ' ] ,
31+ $ item = Arr:: get ($ field, ' Item ' );
32+ $ itemElementName = Arr:: get ( $ field , ' ItemElementName ' ) ;
33+
34+ return match ( $ itemElementName ) {
35+ ' Int ' => ( int ) $ item ,
36+ 'String ' => (string ) $ item ,
37+ 'Decimal ' => (float ) $ item ,
38+ 'Date ' , 'DateTime ' => self ::date ($ item ),
39+ 'Keywords ' => Arr:: join ( $ item [ ' Keyword ' ] , ', ' ),
40+ 'Table ' => self ::table ($ item ),
41+ default => $ default ,
4142 };
4243 }
4344
0 commit comments