Skip to content

Commit 6955d2d

Browse files
authored
Check if column value is a null type when decoding historical data (#58)
Also check if column value is a null type In addition to checking if the column value is a string of 'null', also check if the column value is actually`null`.
1 parent e96f7ac commit 6955d2d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ResultDecoder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,13 @@ private function createHistoricalData(array $json, int $index): HistoricalData
228228

229229
foreach (['open', 'high', 'low', 'close', 'volume'] as $column) {
230230
$columnValue = $json['indicators']['quote'][0][$column][$index];
231-
if (!is_numeric($columnValue) && 'null' !== $columnValue) {
231+
if (!is_numeric($columnValue) && 'null' !== $columnValue && !\is_null($columnValue)) {
232232
throw new ApiException(\sprintf('Not a number in column "%s": %s', $column, $column), ApiException::INVALID_VALUE);
233233
}
234234
}
235235

236236
$columnValue = $json['indicators']['adjclose'][0]['adjclose'][$index];
237-
if (!is_numeric($columnValue) && 'null' !== $columnValue) {
237+
if (!is_numeric($columnValue) && 'null' !== $columnValue && !\is_null($columnValue)) {
238238
throw new ApiException(\sprintf('Not a number in column "%s": %s', 'adjclose', 'adjclose'), ApiException::INVALID_VALUE);
239239
}
240240

0 commit comments

Comments
 (0)