From 30a9d5de7ea82ae6aefd246f349e08e6d7ba4c75 Mon Sep 17 00:00:00 2001 From: Turdaliev Nursultan Date: Tue, 14 Jan 2020 13:34:33 +0100 Subject: [PATCH] Update Point.php Move data validation checks up. I think, this way we could prevent execution of any code if the value we are expecting is not valid. --- src/InfluxDB/Point.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/InfluxDB/Point.php b/src/InfluxDB/Point.php index 11bd16e..054cbc7 100644 --- a/src/InfluxDB/Point.php +++ b/src/InfluxDB/Point.php @@ -52,8 +52,14 @@ public function __construct( if (empty($measurement)) { throw new DatabaseException('Invalid measurement name provided'); } + + if ($timestamp && !$this->isValidTimeStamp($timestamp)) { + throw new DatabaseException(sprintf('%s is not a valid timestamp', $timestamp)); + } $this->measurement = (string) $measurement; + $this->timestamp = $timestamp; + $this->setTags($tags); $fields = $additionalFields; @@ -62,12 +68,6 @@ public function __construct( } $this->setFields($fields); - - if ($timestamp && !$this->isValidTimeStamp($timestamp)) { - throw new DatabaseException(sprintf('%s is not a valid timestamp', $timestamp)); - } - - $this->timestamp = $timestamp; } /**