Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if column value is a null type when decoding historical data #58

Open
wants to merge 2 commits into
base: 4.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading