@@ -21,6 +21,11 @@ public function getString(string $key):?string {
2121 return $ this ->get ($ key );
2222 }
2323
24+ /** @return array<string> */
25+ public function getMultipleString (string $ key ):array {
26+ return $ this ->getTypedArray ($ key , "string " );
27+ }
28+
2429 public function getInt (string $ key ):?int {
2530 $ value = $ this ->getString ($ key );
2631 if (is_null ($ value ) || strlen ($ value ) === 0 ) {
@@ -30,6 +35,11 @@ public function getInt(string $key):?int {
3035 return (int )$ value ;
3136 }
3237
38+ /** @return array<int> */
39+ public function getMultipleInt (string $ key ):array {
40+ return $ this ->getTypedArray ($ key , "int " );
41+ }
42+
3343 public function getFloat (string $ key ):?float {
3444 $ value = $ this ->getString ($ key );
3545 if (is_null ($ value ) || strlen ($ value ) === 0 ) {
@@ -39,6 +49,11 @@ public function getFloat(string $key):?float {
3949 return (float )$ value ;
4050 }
4151
52+ /** @return array<float> */
53+ public function getMultipleFloat (string $ key ):array {
54+ return $ this ->getTypedArray ($ key , "float " );
55+ }
56+
4257 public function getBool (string $ key ):?bool {
4358 $ value = $ this ->getString ($ key );
4459 if (is_null ($ value ) || strlen ($ value ) === 0 ) {
@@ -48,12 +63,17 @@ public function getBool(string $key):?bool {
4863 return (bool )$ value ;
4964 }
5065
66+ /** @return array<bool> */
67+ public function getMultipleBool (string $ key ):array {
68+ return $ this ->getTypedArray ($ key , "bool " );
69+ }
70+
71+
5172 public function getFile (string $ key ):FileUpload {
5273 /** @var FileUploadInputData|InputDatum[] $params */
5374 $ params = $ this ->fileUploadParameters ?? $ this ->parameters ;
5475
5576 try {
56-
5777 /** @var MultipleInputDatum|FileUpload $file */
5878 $ file = $ params [$ key ];
5979
@@ -63,14 +83,27 @@ public function getFile(string $key):FileUpload {
6383
6484 return $ file ;
6585 }
66- catch (TypeError $ exception ) {
86+ catch (TypeError ) {
6787 throw new DataNotFileUploadException ($ key );
6888 }
6989 }
7090
71- /** @return MultipleInputDatum<FileUpload> */
72- public function getMultipleFile (string $ key ):MultipleInputDatum {
73- return $ this ->get ($ key );
91+ /** @return array<FileUpload> */
92+ public function getMultipleFile (string $ key ):array {
93+ $ multipleFileUpload = $ this ->get ($ key );
94+ if (!$ multipleFileUpload instanceof MultipleInputDatum) {
95+ throw new InputException ("Parameter ' $ key' is not a multiple file input. " );
96+ }
97+
98+ $ array = [];
99+
100+ /** @var FileUpload $file */
101+ foreach ($ multipleFileUpload as $ file ) {
102+ $ name = $ file ->getClientFilename ();
103+ $ array [$ name ] = $ file ;
104+ }
105+
106+ return $ array ;
74107 }
75108
76109 public function getDateTime (
@@ -101,8 +134,30 @@ public function getDateTime(
101134 return $ dateTime ;
102135 }
103136
104- /** @return MultipleInputDatum<DateTime > */
105- public function getMultipleDateTime (string $ key ):MultipleInputDatum {
137+ /** @return array<DateTimeInterface > */
138+ public function getMultipleDateTime (string $ key ):array {
106139 return $ this ->get ($ key );
107140 }
141+
142+ private function getTypedArray (string $ key , string $ typeName ):array {
143+ $ array = [];
144+ $ datum = $ this ->get ($ key );
145+
146+ if (is_null ($ datum )) {
147+ return [];
148+ }
149+
150+ foreach ($ datum as $ item ) {
151+ $ cast = match ($ typeName ) {
152+ "int " => (int )$ item ,
153+ "float " => (float )$ item ,
154+ "bool " => (bool )$ item ,
155+ default => (string )$ item ,
156+ };
157+
158+ array_push ($ array , $ cast );
159+ }
160+
161+ return $ array ;
162+ }
108163}
0 commit comments