Skip to content

Commit

Permalink
Check if column value is a null type when decoding historical data (#58)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
hackerESQ authored Dec 29, 2024
1 parent e96f7ac commit 6955d2d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ResultDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ private function createHistoricalData(array $json, int $index): HistoricalData

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

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

Expand Down

0 comments on commit 6955d2d

Please sign in to comment.