Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola authored Nov 28, 2023
1 parent d7cafa8 commit 9f4b255
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/GeoJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
abstract class GeoJson implements JsonSerializable, JsonUnserializable
{
public const TYPE_LINESTRING = 'LineString';
public const TYPE_LINE_STRING = 'LineString';
public const TYPE_MULTI_LINE_STRING = 'MultiLineString';
public const TYPE_MULTI_POINT = 'MultiPoint';
public const TYPE_MULTI_POLYGON = 'MultiPolygon';
Expand Down Expand Up @@ -97,7 +97,7 @@ final public static function jsonUnserialize($json): self
$args = [];

switch ($type) {
case self::TYPE_LINESTRING:
case self::TYPE_LINE_STRING:
case self::TYPE_MULTI_LINE_STRING:
case self::TYPE_MULTI_POINT:
case self::TYPE_MULTI_POLYGON:
Expand Down Expand Up @@ -170,7 +170,7 @@ final public static function jsonUnserialize($json): self
$args[] = CoordinateReferenceSystem::jsonUnserialize($json['crs']);
}

$class = sprintf('GeoJson\%s\%s', (strncmp(self::TYPE_FEATURE, $type, 7) === 0 ? self::TYPE_FEATURE : 'Geometry'), $type);
$class = sprintf('GeoJson\%s\%s', (strncmp('Feature', $type, 7) === 0 ? 'Feature' : 'Geometry'), $type);

return new $class(... $args);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/LineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class LineString extends MultiPoint
{
protected string $type = self::TYPE_LINESTRING;
protected string $type = self::TYPE_LINE_STRING;

/**
* @param array<Point|array<float|int>> $positions
Expand Down
2 changes: 1 addition & 1 deletion tests/GeoJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function provideJsonDecodeAssocOptions()
public function provideGeoJsonTypesWithCoordinates()
{
return [
GeoJson::TYPE_LINESTRING => [GeoJson::TYPE_LINESTRING],
GeoJson::TYPE_LINE_STRING => [GeoJson::TYPE_LINE_STRING],
GeoJson::TYPE_MULTI_LINE_STRING => [GeoJson::TYPE_MULTI_LINE_STRING],
GeoJson::TYPE_MULTI_POINT => [GeoJson::TYPE_MULTI_POINT],
GeoJson::TYPE_MULTI_POLYGON => [GeoJson::TYPE_MULTI_POLYGON],
Expand Down
6 changes: 3 additions & 3 deletions tests/Geometry/LineStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public function testSerialization(): void
$lineString = new LineString($coordinates);

$expected = [
'type' => GeoJson::TYPE_LINESTRING,
'type' => GeoJson::TYPE_LINE_STRING,
'coordinates' => $coordinates,
];

$this->assertSame(GeoJson::TYPE_LINESTRING, $lineString->getType());
$this->assertSame(GeoJson::TYPE_LINE_STRING, $lineString->getType());
$this->assertSame($coordinates, $lineString->getCoordinates());
$this->assertSame($expected, $lineString->jsonSerialize());
}
Expand All @@ -73,7 +73,7 @@ public function testUnserialization($assoc): void
$expectedCoordinates = [[1, 1], [2, 2]];

$this->assertInstanceOf(LineString::class, $lineString);
$this->assertSame(GeoJson::TYPE_LINESTRING, $lineString->getType());
$this->assertSame(GeoJson::TYPE_LINE_STRING, $lineString->getType());
$this->assertSame($expectedCoordinates, $lineString->getCoordinates());
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Geometry/LinearRingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public function testSerialization(): void
$linearRing = new LinearRing($coordinates);

$expected = [
'type' => GeoJson::TYPE_LINESTRING,
'type' => GeoJson::TYPE_LINE_STRING,
'coordinates' => $coordinates,
];

$this->assertSame(GeoJson::TYPE_LINESTRING, $linearRing->getType());
$this->assertSame(GeoJson::TYPE_LINE_STRING, $linearRing->getType());
$this->assertSame($coordinates, $linearRing->getCoordinates());
$this->assertSame($expected, $linearRing->jsonSerialize());
}
Expand Down

0 comments on commit 9f4b255

Please sign in to comment.