@@ -506,14 +506,14 @@ public function getFunctions(): array
506506 }),
507507 new TwigFunction ('parse_value ' , function (array $ property , string $ mapAccess , string $ v ) {
508508 $ required = $ property ['required ' ] ?? false ;
509-
509+
510510 // Handle sub_schema
511511 if (isset ($ property ['sub_schema ' ]) && !empty ($ property ['sub_schema ' ])) {
512512 $ subSchema = \ucfirst ($ property ['sub_schema ' ]);
513-
513+
514514 if ($ property ['type ' ] === 'array ' ) {
515- $ arraySource = $ required
516- ? "((IEnumerable<object>) {$ mapAccess }) "
515+ $ arraySource = $ required
516+ ? "((IEnumerable<object>) {$ mapAccess }) "
517517 : "( {$ v } as IEnumerable<object>)? " ;
518518 return "{$ arraySource }.Select(it => {$ subSchema }.From(map: (Dictionary<string, object>)it)).ToList() " ;
519519 } else {
@@ -523,7 +523,7 @@ public function getFunctions(): array
523523 return "( {$ v } as Dictionary<string, object>) is { } obj ? {$ subSchema }.From(map: obj) : null " ;
524524 }
525525 }
526-
526+
527527 // Handle enum
528528 if (isset ($ property ['enum ' ]) && !empty ($ property ['enum ' ])) {
529529 $ enumName = $ property ['enumName ' ] ?? $ property ['name ' ];
@@ -534,46 +534,46 @@ public function getFunctions(): array
534534 }
535535 return "{$ v } == null ? null : new {$ enumClass }( {$ v }.ToString()) " ;
536536 }
537-
537+
538538 // Handle arrays
539539 if ($ property ['type ' ] === 'array ' ) {
540540 $ itemsType = $ property ['items ' ]['type ' ] ?? 'object ' ;
541541 $ src = $ required ? $ mapAccess : $ v ;
542- $ arraySource = $ required
543- ? "((IEnumerable<object>) {$ src }) "
542+ $ arraySource = $ required
543+ ? "((IEnumerable<object>) {$ src }) "
544544 : "( {$ src } as IEnumerable<object>)? " ;
545-
546- $ selectExpression = match ($ itemsType ) {
545+
546+ $ selectExpression = match ($ itemsType ) {
547547 'string ' => 'x.ToString() ' ,
548548 'integer ' => 'Convert.ToInt64(x) ' ,
549549 'number ' => 'Convert.ToDouble(x) ' ,
550550 'boolean ' => '(bool)x ' ,
551551 default => 'x '
552552 };
553-
553+
554554 return "{$ arraySource }.Select(x => {$ selectExpression }).ToList() " ;
555555 }
556-
556+
557557 // Handle integer/number
558558 if ($ property ['type ' ] === 'integer ' || $ property ['type ' ] === 'number ' ) {
559559 $ convertMethod = $ property ['type ' ] === 'integer ' ? 'Int64 ' : 'Double ' ;
560-
560+
561561 if ($ required ) {
562562 return "Convert.To {$ convertMethod }( {$ mapAccess }) " ;
563563 }
564564 return "{$ v } == null ? null : Convert.To {$ convertMethod }( {$ v }) " ;
565565 }
566-
566+
567567 // Handle boolean
568568 if ($ property ['type ' ] === 'boolean ' ) {
569569 $ typeName = $ this ->getTypeName ($ property );
570-
570+
571571 if ($ required ) {
572572 return "( {$ typeName }) {$ mapAccess }" ;
573573 }
574574 return "( {$ typeName }?) {$ v }" ;
575575 }
576-
576+
577577 // Handle string type
578578 if ($ required ) {
579579 return "{$ mapAccess }.ToString() " ;
0 commit comments