Skip to content

Commit 7be4fa6

Browse files
author
Matan Yadaev
committed
Make Geometry::toWkt parameters optional
1 parent 446f18a commit 7be4fa6

File tree

9 files changed

+21
-8
lines changed

9 files changed

+21
-8
lines changed

src/GeometryCast.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(string $className)
2929
* @param string $key
3030
* @param string|Expression|null $wkbOrWKt
3131
* @param array<string, mixed> $attributes
32+
*
3233
* @return Geometry|null
3334
*/
3435
public function get($model, string $key, $wkbOrWKt, array $attributes): ?Geometry
@@ -51,6 +52,7 @@ public function get($model, string $key, $wkbOrWKt, array $attributes): ?Geometr
5152
* @param string $key
5253
* @param Geometry|mixed|null $geometry
5354
* @param array<string, mixed> $attributes
55+
*
5456
* @return Expression|null
5557
*
5658
* @throws InvalidArgumentException

src/Objects/Geometry.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
abstract class Geometry implements Castable, Arrayable, Jsonable, JsonSerializable
1818
{
19-
abstract public function toWkt(bool $withFunction): string;
19+
abstract public function toWkt(bool $withFunction = true): string;
2020

2121
/**
2222
* @param int $options
23+
*
2324
* @return string
2425
*
2526
* @throws JsonException
@@ -31,6 +32,7 @@ public function toJson($options = 0): string
3132

3233
/**
3334
* @param string $wkb
35+
*
3436
* @return static
3537
*
3638
* @throws InvalidArgumentException
@@ -50,6 +52,7 @@ public static function fromWkb(string $wkb): static
5052

5153
/**
5254
* @param string $wkt
55+
*
5356
* @return static
5457
*
5558
* @throws InvalidArgumentException
@@ -69,6 +72,7 @@ public static function fromWkt(string $wkt): static
6972

7073
/**
7174
* @param string $geoJson
75+
*
7276
* @return static
7377
*
7478
* @throws InvalidArgumentException
@@ -143,6 +147,7 @@ abstract public function getCoordinates(): array;
143147

144148
/**
145149
* @param array<string> $arguments
150+
*
146151
* @return CastsAttributes
147152
*/
148153
public static function castUsing(array $arguments): CastsAttributes

src/Objects/GeometryCollection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ public function __construct(Collection|array $geometries)
4343

4444
/**
4545
* @param bool $withFunction
46+
*
4647
* @return string
4748
*
4849
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
4950
*/
50-
public function toWkt(bool $withFunction): string
51+
public function toWkt(bool $withFunction = true): string
5152
{
5253
$wkt = $this->toCollectionWkt(withFunction: true);
5354

@@ -94,6 +95,7 @@ public function getGeometries(): Collection
9495

9596
/**
9697
* @param int $offset
98+
*
9799
* @return bool
98100
*/
99101
public function offsetExists($offset): bool
@@ -103,6 +105,7 @@ public function offsetExists($offset): bool
103105

104106
/**
105107
* @param int $offset
108+
*
106109
* @return TGeometry|null
107110
*/
108111
public function offsetGet($offset): ?Geometry

src/Objects/LineString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class LineString extends PointCollection
88
{
99
protected int $minimumGeometries = 2;
1010

11-
public function toWkt(bool $withFunction): string
11+
public function toWkt(bool $withFunction = true): string
1212
{
1313
$wkt = $this->toCollectionWkt(withFunction: false);
1414

src/Objects/MultiLineString.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ class MultiLineString extends GeometryCollection
1818

1919
/**
2020
* @param bool $withFunction
21+
*
2122
* @return string
2223
*
2324
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
2425
*/
25-
public function toWkt(bool $withFunction): string
26+
public function toWkt(bool $withFunction = true): string
2627
{
2728
$wkt = $this->toCollectionWkt(withFunction: false);
2829

src/Objects/MultiPoint.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ class MultiPoint extends PointCollection
1010

1111
/**
1212
* @param bool $withFunction
13+
*
1314
* @return string
1415
*
1516
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
1617
*/
17-
public function toWkt(bool $withFunction): string
18+
public function toWkt(bool $withFunction = true): string
1819
{
1920
$wkt = $this->toCollectionWkt(withFunction: false);
2021

src/Objects/MultiPolygon.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ class MultiPolygon extends GeometryCollection
1818

1919
/**
2020
* @param bool $withFunction
21+
*
2122
* @return string
2223
*
2324
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
2425
*/
25-
public function toWkt(bool $withFunction): string
26+
public function toWkt(bool $withFunction = true): string
2627
{
2728
$wkt = $this->toCollectionWkt(withFunction: false);
2829

src/Objects/Point.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(float $latitude, float $longitude)
1616
$this->longitude = $longitude;
1717
}
1818

19-
public function toWkt(bool $withFunction): string
19+
public function toWkt(bool $withFunction = true): string
2020
{
2121
$wkt = "{$this->longitude} {$this->latitude}";
2222

src/Objects/Polygon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Polygon extends MultiLineString
88
{
9-
public function toWkt(bool $withFunction): string
9+
public function toWkt(bool $withFunction = true): string
1010
{
1111
$wkt = $this->toCollectionWkt(withFunction: false);
1212

0 commit comments

Comments
 (0)