@@ -45,6 +45,14 @@ class DigikeyProvider implements InfoProviderInterface
45
45
46
46
private readonly HttpClientInterface $ digikeyClient ;
47
47
48
+ /**
49
+ * A list of parameter IDs, that are always assumed as text only and will never be converted to a numerical value.
50
+ * This allows to fix issues like #682, where the "Supplier Device Package" was parsed as a numerical value.
51
+ */
52
+ private const TEXT_ONLY_PARAMETERS = [
53
+ 1291 , //Supplier Device Package
54
+ 39246 , //Package / Case
55
+ ];
48
56
49
57
public function __construct (HttpClientInterface $ httpClient , private readonly OAuthTokenManager $ authTokenManager ,
50
58
private readonly string $ currency , private readonly string $ clientId ,
@@ -214,7 +222,12 @@ private function parametersToDTOs(array $parameters, string|null &$footprint_nam
214
222
continue ;
215
223
}
216
224
217
- $ results [] = ParameterDTO::parseValueIncludingUnit ($ parameter ['Parameter ' ], $ parameter ['Value ' ]);
225
+ //If the parameter was marked as text only, then we do not try to parse it as a numerical value
226
+ if (in_array ($ parameter ['ParameterId ' ], self ::TEXT_ONLY_PARAMETERS , true )) {
227
+ $ results [] = new ParameterDTO (name: $ parameter ['Parameter ' ], value_text: $ parameter ['Value ' ]);
228
+ } else { //Otherwise try to parse it as a numerical value
229
+ $ results [] = ParameterDTO::parseValueIncludingUnit ($ parameter ['Parameter ' ], $ parameter ['Value ' ]);
230
+ }
218
231
}
219
232
220
233
return $ results ;
0 commit comments