File tree 2 files changed +49
-1
lines changed
2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ public function mapRawData(array $data)
133
133
continue ;
134
134
}
135
135
136
- if (!array_key_exists ( $ field , $ this ->map )) {
136
+ if (!$ this ->isFieldKnown ( $ field )) {
137
137
// silently ignore unknown fields
138
138
continue ;
139
139
}
@@ -214,6 +214,33 @@ protected function isSection($field)
214
214
return (in_array ($ field , $ this ->sections ));
215
215
}
216
216
217
+ /**
218
+ * Determines if the given field is known,
219
+ * in a case insensitive way for its first letter.
220
+ * Also update $field to keep it valid against the known fields.
221
+ *
222
+ * @param string &$field
223
+ * @return bool
224
+ */
225
+ protected function isFieldKnown (&$ field )
226
+ {
227
+ $ lcfField = lcfirst ($ field );
228
+ if (array_key_exists ($ lcfField , $ this ->map )) {
229
+ $ field = $ lcfField ;
230
+
231
+ return true ;
232
+ }
233
+
234
+ $ ucfField = ucfirst ($ field );
235
+ if (array_key_exists ($ ucfField , $ this ->map )) {
236
+ $ field = $ ucfField ;
237
+
238
+ return true ;
239
+ }
240
+
241
+ return false ;
242
+ }
243
+
217
244
/**
218
245
* Extract GPS coordinates from components array
219
246
*
Original file line number Diff line number Diff line change @@ -191,6 +191,27 @@ public function testMapRawDataFlattensRawDataWithSections()
191
191
$ this ->assertEquals ($ expected , $ keys );
192
192
}
193
193
194
+ /**
195
+ * @group mapper
196
+ * @covers \PHPExif\Mapper\Native::mapRawData
197
+ */
198
+ public function testMapRawDataMacthesFieldsWithoutCaseSensibilityOnFirstLetter ()
199
+ {
200
+ $ rawData = array (
201
+ \PHPExif \Mapper \Native::ORIENTATION => 'Portrait ' ,
202
+ 'Copyright ' => 'Acme ' ,
203
+ );
204
+ $ mapped = $ this ->mapper ->mapRawData ($ rawData );
205
+ $ this ->assertCount (2 , $ mapped );
206
+ $ keys = array_keys ($ mapped );
207
+
208
+ $ expected = array (
209
+ \PHPExif \Mapper \Native::ORIENTATION ,
210
+ \PHPExif \Mapper \Native::COPYRIGHT
211
+ );
212
+ $ this ->assertEquals ($ expected , $ keys );
213
+ }
214
+
194
215
/**
195
216
* @group mapper
196
217
* @covers \PHPExif\Mapper\Native::mapRawData
You can’t perform that action at this time.
0 commit comments