Skip to content

Commit

Permalink
AbstractPlatform no longer uses an array constructor for SpatialInter…
Browse files Browse the repository at this point in the history
…face (#84)
  • Loading branch information
Alexandre-T authored Jun 8, 2024
1 parent 03cbcf4 commit 30c5981
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/LongitudeOne/Spatial/DBAL/Platform/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use LongitudeOne\Spatial\DBAL\Types\GeographyType;
use LongitudeOne\Spatial\Exception\InvalidValueException;
use LongitudeOne\Spatial\Exception\MissingArgumentException;
use LongitudeOne\Spatial\PHP\Types\PointInterface;
use LongitudeOne\Spatial\PHP\Types\SpatialInterface;

/**
Expand Down Expand Up @@ -177,10 +178,12 @@ private function newObjectFromValue(DoctrineSpatialTypeInterface $type, array $v
/** @var class-string<SpatialInterface> $class */
$class = sprintf('LongitudeOne\Spatial\PHP\Types\%s\%s', $typeFamily, $constValue);

if (isset($value['srid'])) {
return new $class($value['value'], $value['srid']);
if (is_a($class, PointInterface::class, true)) {
if (is_array($value['value']) && isset($value['value'][0], $value['value'][1])) {
return new $class($value['value'][0], $value['value'][1], $value['srid'] ?? null);
}
}

return new $class($value['value']);
return new $class($value['value'], $value['srid'] ?? null);
}
}

0 comments on commit 30c5981

Please sign in to comment.