Skip to content

Commit

Permalink
Add support for custom properties in toFeatureCollectionJson method
Browse files Browse the repository at this point in the history
  • Loading branch information
Holly committed Mar 29, 2024
1 parent 568aba4 commit 367c343
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Objects/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function toArray(): array
/**
* @throws JsonException
*/
public function toFeatureCollectionJson(): string
public function toFeatureCollectionJson(array $properties = []): string

Check failure on line 158 in src/Objects/Geometry.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Method MatanYadaev\EloquentSpatial\Objects\Geometry::toFeatureCollectionJson() has parameter $properties with no value type specified in iterable type array.

Check failure on line 158 in src/Objects/Geometry.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Method MatanYadaev\EloquentSpatial\Objects\Geometry::toFeatureCollectionJson() has parameter $properties with no value type specified in iterable type array.
{
if (static::class === GeometryCollection::class) {
/** @var GeometryCollection $this */
Expand All @@ -164,10 +164,10 @@ public function toFeatureCollectionJson(): string
$geometries = collect([$this]);
}

$features = $geometries->map(static function (self $geometry): array {
$features = $geometries->map(static function (self $geometry, $index) use ($properties) {
return [
'type' => 'Feature',
'properties' => [],
'properties' => $properties[$index] ?? [],
'geometry' => $geometry->toArray(),
];
});
Expand Down

0 comments on commit 367c343

Please sign in to comment.