From 5bc2b9fabd018a4b0243021e1666f2fffe032280 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 20 Jul 2015 09:54:00 -0300 Subject: [PATCH] Use native type-checking --- src/InfluxDB/Database.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/InfluxDB/Database.php b/src/InfluxDB/Database.php index 3540aa8283..713fa27533 100644 --- a/src/InfluxDB/Database.php +++ b/src/InfluxDB/Database.php @@ -117,15 +117,12 @@ class Database */ public function writePoints(array $points, $precision = self::PRECISION_NANOSECONDS) { - $payload = array(); - - foreach ($points as $point) { - if (! $point instanceof Point) { - throw new \InvalidArgumentException('An array of Point[] should be passed'); - } - - $payload[] = (string) $point; - } + $payload = array_map( + function (Point $point) { + return (string) $point; + }, + $points + ); return $this->client->write($this->name, implode(PHP_EOL, $payload), $precision); } @@ -190,7 +187,6 @@ class Database */ protected function getRetentionPolicyQuery($method, RetentionPolicy $retentionPolicy) { - if (!in_array($method, array('CREATE', 'ALTER'))) { throw new \InvalidArgumentException(sprintf('%s is not a valid method')); }