From 32af9cfdbcaecaa86a83646eb79ea46ca8dd8eb5 Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Wed, 25 Dec 2024 23:02:21 -0600 Subject: [PATCH 1/2] 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`. --- src/ResultDecoder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ResultDecoder.php b/src/ResultDecoder.php index 35f9bb0..24ce018 100644 --- a/src/ResultDecoder.php +++ b/src/ResultDecoder.php @@ -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); } From f104fe603d503f0b77a1dce3f5c969bb9cdfcfcf Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Sat, 28 Dec 2024 17:12:22 -0600 Subject: [PATCH 2/2] make php-cs-fixer happy --- src/ResultDecoder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ResultDecoder.php b/src/ResultDecoder.php index 24ce018..1e15eed 100644 --- a/src/ResultDecoder.php +++ b/src/ResultDecoder.php @@ -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 && !is_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 && !is_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); }