From bc6366c65f0ca3c52447ce853194d047e4bf2bdc Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Mon, 6 Feb 2023 10:50:48 -0800 Subject: [PATCH] places: refactor string interpolation --- lib/Command/PlacesSetup.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Command/PlacesSetup.php b/lib/Command/PlacesSetup.php index c66e4c1d..f525112f 100644 --- a/lib/Command/PlacesSetup.php +++ b/lib/Command/PlacesSetup.php @@ -202,19 +202,22 @@ class PlacesSetup extends Command $query = $this->connection->getQueryBuilder(); if (GIS_TYPE_MYSQL === $this->gisType) { - $points = array_map(function ($point) { - return $point[0].' '.$point[1]; - }, $coords); - $geometry = implode(',', $points); + $points = implode(',', array_map(function (&$point) { + $x = $point[0]; + $y = $point[1]; - $geometry = 'POLYGON(('.$geometry.'))'; - $geometry = 'ST_GeomFromText(\''.$geometry.'\')'; + return "{$x} {$y}"; + }, $coords)); + + $geometry = "ST_GeomFromText('POLYGON(({$points}))')"; } elseif (GIS_TYPE_POSTGRES === $this->gisType) { - $points = array_map(function ($point) { - return '('.$point[0].','.$point[1].')'; - }, $coords); - $geometry = implode(',', $points); - $geometry = 'POLYGON(\''.$geometry.'\')'; + $points = implode(',', array_map(function (&$point) { + $x = $point[0]; + $y = $point[1]; + + return "({$x},{$y})"; + }, $coords)); + $geometry = "POLYGON('{$points}')"; } try {