Skip to content

Commit

Permalink
Check if column value is a null type when decoding historical data (s…
Browse files Browse the repository at this point in the history
…cheb#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`.
  • Loading branch information
hackerESQ authored and krivov committed Jan 16, 2025
1 parent c356b93 commit f8980d8
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 @@ -250,13 +250,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 f8980d8

Please sign in to comment.