Skip to content

Commit 57d87d0

Browse files
committed
Apply ECS
1 parent fab9050 commit 57d87d0

File tree

87 files changed

+2002
-1704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2002
-1704
lines changed

src/BoundingBox.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
use Brick\Geo\Exception\CoordinateSystemException;
88
use Brick\Geo\Exception\EmptyGeometryException;
99

10+
use function assert;
11+
use function max;
12+
use function min;
13+
1014
/**
1115
* Represents a 2D or 3D bounding box calculated from a set of points. M coordinates are ignored.
1216
* This class is immutable.
@@ -48,7 +52,7 @@ public static function new(): BoundingBox
4852
*
4953
* @throws CoordinateSystemException
5054
*/
51-
public function extendedWithPoint(Point $point) : BoundingBox
55+
public function extendedWithPoint(Point $point): BoundingBox
5256
{
5357
if ($point->isEmpty()) {
5458
return $this;
@@ -106,7 +110,7 @@ public function extendedWithPoint(Point $point) : BoundingBox
106110
*
107111
* @throws CoordinateSystemException
108112
*/
109-
public function extendedWithBoundingBox(BoundingBox $boundingBox) : BoundingBox
113+
public function extendedWithBoundingBox(BoundingBox $boundingBox): BoundingBox
110114
{
111115
if ($boundingBox->isEmpty()) {
112116
return $this;
@@ -117,7 +121,7 @@ public function extendedWithBoundingBox(BoundingBox $boundingBox) : BoundingBox
117121
->extendedWithPoint($boundingBox->getNorthEast());
118122
}
119123

120-
public function isEmpty() : bool
124+
public function isEmpty(): bool
121125
{
122126
return $this->cs === null;
123127
}
@@ -127,7 +131,7 @@ public function isEmpty() : bool
127131
*
128132
* @throws EmptyGeometryException
129133
*/
130-
public function getSouthWest() : Point
134+
public function getSouthWest(): Point
131135
{
132136
if ($this->cs === null) {
133137
throw new EmptyGeometryException('The bounding box is empty.');
@@ -151,7 +155,7 @@ public function getSouthWest() : Point
151155
*
152156
* @throws EmptyGeometryException
153157
*/
154-
public function getNorthEast() : Point
158+
public function getNorthEast(): Point
155159
{
156160
if ($this->cs === null) {
157161
throw new EmptyGeometryException('The bounding box is empty.');

src/CircularString.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,26 @@
1111
use Brick\Geo\Exception\InvalidGeometryException;
1212
use Brick\Geo\Exception\NoSuchGeometryException;
1313
use Brick\Geo\Projector\Projector;
14+
use Countable;
15+
use IteratorAggregate;
1416
use Override;
1517

18+
use function array_map;
19+
use function array_reduce;
20+
use function array_values;
21+
use function count;
22+
1623
/**
1724
* A CircularString is a Curve made of zero or more connected circular arc segments.
1825
*
1926
* A circular arc segment is a curved segment defined by three points in a two-dimensional plane;
2027
* the first point cannot be the same as the third point.
2128
*
22-
* @template-implements \IteratorAggregate<int<0, max>, Point>
29+
* @template-implements IteratorAggregate<int<0, max>, Point>
30+
*
2331
* @final
2432
*/
25-
class CircularString extends Curve implements \Countable, \IteratorAggregate
33+
class CircularString extends Curve implements Countable, IteratorAggregate
2634
{
2735
/**
2836
* The Points that compose this CircularString.
@@ -63,19 +71,19 @@ public function __construct(CoordinateSystem $cs, Point ...$points)
6371
/**
6472
* Creates a non-empty CircularString composed of the given points.
6573
*
66-
* @param Point $point1 The first point.
74+
* @param Point $point1 The first point.
6775
* @param Point ...$pointN The subsequent points.
6876
*
6977
* @throws InvalidGeometryException If the number of points is invalid.
7078
* @throws CoordinateSystemException If the points use different coordinate systems.
7179
*/
72-
public static function of(Point $point1, Point ...$pointN) : CircularString
80+
public static function of(Point $point1, Point ...$pointN): CircularString
7381
{
7482
return new CircularString($point1->coordinateSystem(), $point1, ...$pointN);
7583
}
7684

7785
#[Override]
78-
public function startPoint() : Point
86+
public function startPoint(): Point
7987
{
8088
if (count($this->points) === 0) {
8189
throw new EmptyGeometryException('The CircularString is empty and has no start point.');
@@ -85,7 +93,7 @@ public function startPoint() : Point
8593
}
8694

8795
#[Override]
88-
public function endPoint() : Point
96+
public function endPoint(): Point
8997
{
9098
$count = count($this->points);
9199

@@ -99,7 +107,7 @@ public function endPoint() : Point
99107
/**
100108
* Returns the number of Points in this CircularString.
101109
*/
102-
public function numPoints() : int
110+
public function numPoints(): int
103111
{
104112
return count($this->points);
105113
}
@@ -111,7 +119,7 @@ public function numPoints() : int
111119
*
112120
* @throws NoSuchGeometryException If there is no Point at this index.
113121
*/
114-
public function pointN(int $n) : Point
122+
public function pointN(int $n): Point
115123
{
116124
if (! isset($this->points[$n - 1])) {
117125
throw new NoSuchGeometryException('There is no Point in this CircularString at index ' . $n);
@@ -125,25 +133,25 @@ public function pointN(int $n) : Point
125133
*
126134
* @return list<Point>
127135
*/
128-
public function points() : array
136+
public function points(): array
129137
{
130138
return $this->points;
131139
}
132140

133141
#[NoProxy, Override]
134-
public function geometryType() : string
142+
public function geometryType(): string
135143
{
136144
return 'CircularString';
137145
}
138146

139147
#[NoProxy, Override]
140-
public function geometryTypeBinary() : int
148+
public function geometryTypeBinary(): int
141149
{
142150
return Geometry::CIRCULARSTRING;
143151
}
144152

145153
#[Override]
146-
public function getBoundingBox() : BoundingBox
154+
public function getBoundingBox(): BoundingBox
147155
{
148156
return array_reduce(
149157
$this->points,
@@ -156,7 +164,7 @@ public function getBoundingBox() : BoundingBox
156164
* @return list<list<float>>
157165
*/
158166
#[Override]
159-
public function toArray() : array
167+
public function toArray(): array
160168
{
161169
return array_map(
162170
fn (Point $point) => $point->toArray(),
@@ -180,7 +188,7 @@ public function project(Projector $projector): CircularString
180188
* Returns the number of points in this CircularString.
181189
*/
182190
#[Override]
183-
public function count() : int
191+
public function count(): int
184192
{
185193
return count($this->points);
186194
}
@@ -191,7 +199,7 @@ public function count() : int
191199
* @return ArrayIterator<int<0, max>, Point>
192200
*/
193201
#[Override]
194-
public function getIterator() : ArrayIterator
202+
public function getIterator(): ArrayIterator
195203
{
196204
return new ArrayIterator($this->points);
197205
}

src/CompoundCurve.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* A CompoundCurve is a collection of zero or more continuous CircularString or LineString instances.
2525
*
26-
* @template-implements \IteratorAggregate<int<0, max>, LineString|CircularString>
26+
* @template-implements IteratorAggregate<int<0, max>, LineString|CircularString>
2727
*
2828
* @final
2929
*/

src/CoordinateSystem.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,55 +43,55 @@ public function __construct(bool $hasZ, bool $hasM, int $srid = 0)
4343
/**
4444
* Returns a CoordinateSystem with X and Y coordinates, and an optional SRID.
4545
*/
46-
public static function xy(int $srid = 0) : CoordinateSystem
46+
public static function xy(int $srid = 0): CoordinateSystem
4747
{
4848
return new self(false, false, $srid);
4949
}
5050

5151
/**
5252
* Returns a CoordinateSystem with X, Y and Z coordinates, and an optional SRID.
5353
*/
54-
public static function xyz(int $srid = 0) : CoordinateSystem
54+
public static function xyz(int $srid = 0): CoordinateSystem
5555
{
5656
return new self(true, false, $srid);
5757
}
5858

5959
/**
6060
* Returns a CoordinateSystem with X, Y and M coordinates, and an optional SRID.
6161
*/
62-
public static function xym(int $srid = 0) : CoordinateSystem
62+
public static function xym(int $srid = 0): CoordinateSystem
6363
{
6464
return new self(false, true, $srid);
6565
}
6666

6767
/**
6868
* Returns a CoordinateSystem with X, Y, Z and M coordinates, and an optional SRID.
6969
*/
70-
public static function xyzm(int $srid = 0) : CoordinateSystem
70+
public static function xyzm(int $srid = 0): CoordinateSystem
7171
{
7272
return new self(true, true, $srid);
7373
}
7474

7575
/**
7676
* Returns whether this coordinate system has Z-coordinates.
7777
*/
78-
public function hasZ() : bool
78+
public function hasZ(): bool
7979
{
8080
return $this->hasZ;
8181
}
8282

8383
/**
8484
* Returns whether this coordinate system has M-coordinates.
8585
*/
86-
public function hasM() : bool
86+
public function hasM(): bool
8787
{
8888
return $this->hasM;
8989
}
9090

9191
/**
9292
* Returns the Spatial Reference System Identifier of this coordinate system.
9393
*/
94-
public function srid() : int
94+
public function srid(): int
9595
{
9696
return $this->srid;
9797
}
@@ -101,7 +101,7 @@ public function srid() : int
101101
*
102102
* @return 'XY'|'XYZ'|'XYM'|'XYZM'
103103
*/
104-
public function coordinateName() : string
104+
public function coordinateName(): string
105105
{
106106
$name = 'XY';
107107

@@ -129,7 +129,7 @@ public function coordinateName() : string
129129
*
130130
* @return int<2, 4>
131131
*/
132-
public function coordinateDimension() : int
132+
public function coordinateDimension(): int
133133
{
134134
$coordinateDimension = 2;
135135

@@ -151,15 +151,15 @@ public function coordinateDimension() : int
151151
*
152152
* @return int<2, 3>
153153
*/
154-
public function spatialDimension() : int
154+
public function spatialDimension(): int
155155
{
156156
return $this->hasZ ? 3 : 2;
157157
}
158158

159159
/**
160160
* Returns a copy of this CoordinateSystem with the $hasZ altered.
161161
*/
162-
public function withZ(bool $hasZ) : CoordinateSystem
162+
public function withZ(bool $hasZ): CoordinateSystem
163163
{
164164
if ($hasZ === $this->hasZ) {
165165
return $this;
@@ -171,7 +171,7 @@ public function withZ(bool $hasZ) : CoordinateSystem
171171
/**
172172
* Returns a copy of this CoordinateSystem with the $hasM altered.
173173
*/
174-
public function withM(bool $hasM) : CoordinateSystem
174+
public function withM(bool $hasM): CoordinateSystem
175175
{
176176
if ($hasM === $this->hasM) {
177177
return $this;
@@ -183,7 +183,7 @@ public function withM(bool $hasM) : CoordinateSystem
183183
/**
184184
* Returns a copy of this CoordinateSystem with the SRID altered.
185185
*/
186-
public function withSrid(int $srid) : CoordinateSystem
186+
public function withSrid(int $srid): CoordinateSystem
187187
{
188188
if ($srid === $this->srid) {
189189
return $this;
@@ -192,20 +192,20 @@ public function withSrid(int $srid) : CoordinateSystem
192192
return new CoordinateSystem($this->hasZ, $this->hasM, $srid);
193193
}
194194

195-
public function isEqualTo(CoordinateSystem $that) : bool
195+
public function isEqualTo(CoordinateSystem $that): bool
196196
{
197197
return $this->hasZ === $that->hasZ
198198
&& $this->hasM === $that->hasM
199199
&& $this->srid === $that->srid;
200200
}
201201

202202
/**
203-
* @param Geometry $reference The geometry holding the reference coordinate system.
203+
* @param Geometry $reference The geometry holding the reference coordinate system.
204204
* @param Geometry ...$geometries The geometries to check against this coordinate system.
205205
*
206206
* @throws CoordinateSystemException If the coordinate systems differ.
207207
*/
208-
public static function check(Geometry $reference, Geometry ...$geometries) : void
208+
public static function check(Geometry $reference, Geometry ...$geometries): void
209209
{
210210
$referenceCs = $reference->coordinateSystem();
211211

src/Curve.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract class Curve extends Geometry
2020
* A Curve is a 1-dimensional geometric object.
2121
*/
2222
#[NoProxy, Override]
23-
public function dimension() : int
23+
public function dimension(): int
2424
{
2525
return 1;
2626
}
@@ -30,14 +30,14 @@ public function dimension() : int
3030
*
3131
* @throws EmptyGeometryException If the curve is empty.
3232
*/
33-
abstract public function startPoint() : Point;
33+
abstract public function startPoint(): Point;
3434

3535
/**
3636
* Returns the end Point of this Curve.
3737
*
3838
* @throws EmptyGeometryException If the curve is empty.
3939
*/
40-
abstract public function endPoint() : Point;
40+
abstract public function endPoint(): Point;
4141

4242
#[Override]
4343
abstract public function project(Projector $projector): Curve;

0 commit comments

Comments
 (0)