From a1c0ddbaad4df54a1b9159dd1e434e10d8f376ab Mon Sep 17 00:00:00 2001 From: Bobby Allen Date: Sun, 4 Dec 2016 19:28:40 +0000 Subject: [PATCH] A few more fixes. --- lib/Core/GeoJSON.php | 8 ++++++-- lib/MultiPoint.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Core/GeoJSON.php b/lib/Core/GeoJSON.php index 7315769..deb10a0 100644 --- a/lib/Core/GeoJSON.php +++ b/lib/Core/GeoJSON.php @@ -60,8 +60,8 @@ public function generateMember() */ private function validateSchema() { - $type_constants = (new \ReflectionClass(__CLASS__))->getConstants(); - if (!in_array($this->type, $type_constants)) { + $typeConstants = (new \ReflectionClass(__CLASS__))->getConstants(); + if (!in_array($this->type, $typeConstants)) { throw new \Ballen\Cartographer\Exceptions\InvalidObjectTypeException(sprintf('The GeoJSON object type specified (%s) is not supported.', $this->type)); } if (!$this->validate()) { @@ -71,11 +71,15 @@ private function validateSchema() /** * Constructs the JSON object. + * @param boolean $pretty Enable "pretty" JSON outputting * @return string */ private function buildJson($pretty = false) { $data = array_merge(['type' => $this->type], $this->export()); + if ($pretty) { + return json_encode($data, JSON_PRETTY_PRINT); + } return json_encode($data); } } diff --git a/lib/MultiPoint.php b/lib/MultiPoint.php index 492a17c..b1738c8 100644 --- a/lib/MultiPoint.php +++ b/lib/MultiPoint.php @@ -40,7 +40,7 @@ public function __construct($init) $this->coordinates = new Collection; if (is_array($init)) { - array_walk($init, function($i) { + array_walk($init, function($item) { if (is_a($item, LatLong::class)) { $this->addCoordinate($item); }