1111use Brick \Geo \Exception \InvalidGeometryException ;
1212use Brick \Geo \Exception \NoSuchGeometryException ;
1313use Brick \Geo \Projector \Projector ;
14+ use Countable ;
15+ use IteratorAggregate ;
1416use 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 CompoundCurve is a collection of zero or more continuous CircularString or LineString instances.
1825 *
1926 * @template-implements \IteratorAggregate<int<0, max>, LineString|CircularString>
27+ *
2028 * @final
2129 */
22- class CompoundCurve extends Curve implements \ Countable, \ IteratorAggregate
30+ class CompoundCurve extends Curve implements Countable, IteratorAggregate
2331{
2432 /**
2533 * The Curves that compose this CompoundCurve.
@@ -33,7 +41,7 @@ class CompoundCurve extends Curve implements \Countable, \IteratorAggregate
3341 /**
3442 * The coordinate system of each of the curves must match the one of the CompoundCurve.
3543 *
36- * @param CoordinateSystem $cs The coordinate system of the CompoundCurve.
44+ * @param CoordinateSystem $cs The coordinate system of the CompoundCurve.
3745 * @param LineString|CircularString ...$curves The curves that compose the CompoundCurve.
3846 *
3947 * @throws EmptyGeometryException If any of the input curves is empty.
@@ -71,20 +79,20 @@ public function __construct(CoordinateSystem $cs, LineString|CircularString ...$
7179 /**
7280 * Creates a non-empty CompoundCurve composed of the given curves.
7381 *
74- * @param LineString|CircularString $curve1 The first curve.
82+ * @param LineString|CircularString $curve1 The first curve.
7583 * @param LineString|CircularString ...$curveN The subsequent curves, if any.
7684 *
7785 * @throws EmptyGeometryException If any of the input curves is empty.
7886 * @throws InvalidGeometryException If the compound curve is not continuous.
7987 * @throws CoordinateSystemException If the curves use different coordinate systems.
8088 */
81- public static function of (LineString |CircularString $ curve1 , LineString |CircularString ...$ curveN ) : CompoundCurve
89+ public static function of (LineString |CircularString $ curve1 , LineString |CircularString ...$ curveN ): CompoundCurve
8290 {
8391 return new CompoundCurve ($ curve1 ->coordinateSystem (), $ curve1 , ...$ curveN );
8492 }
8593
8694 #[Override]
87- public function startPoint () : Point
95+ public function startPoint (): Point
8896 {
8997 if (count ($ this ->curves ) === 0 ) {
9098 throw new EmptyGeometryException ('The CompoundCurve is empty and has no start point. ' );
@@ -94,7 +102,7 @@ public function startPoint() : Point
94102 }
95103
96104 #[Override]
97- public function endPoint () : Point
105+ public function endPoint (): Point
98106 {
99107 $ count = count ($ this ->curves );
100108
@@ -108,7 +116,7 @@ public function endPoint() : Point
108116 /**
109117 * Returns the number of Curves in this CompoundCurve.
110118 */
111- public function numCurves () : int
119+ public function numCurves (): int
112120 {
113121 return count ($ this ->curves );
114122 }
@@ -120,7 +128,7 @@ public function numCurves() : int
120128 *
121129 * @throws NoSuchGeometryException If there is no Curve at this index.
122130 */
123- public function curveN (int $ n ) : LineString |CircularString
131+ public function curveN (int $ n ): LineString |CircularString
124132 {
125133 if (! isset ($ this ->curves [$ n - 1 ])) {
126134 throw new NoSuchGeometryException ('There is no Curve in this CompoundCurve at index ' . $ n );
@@ -134,25 +142,25 @@ public function curveN(int $n) : LineString|CircularString
134142 *
135143 * @return list<LineString|CircularString>
136144 */
137- public function curves () : array
145+ public function curves (): array
138146 {
139147 return $ this ->curves ;
140148 }
141149
142150 #[NoProxy, Override]
143- public function geometryType () : string
151+ public function geometryType (): string
144152 {
145153 return 'CompoundCurve ' ;
146154 }
147155
148156 #[NoProxy, Override]
149- public function geometryTypeBinary () : int
157+ public function geometryTypeBinary (): int
150158 {
151159 return Geometry::COMPOUNDCURVE ;
152160 }
153161
154162 #[Override]
155- public function getBoundingBox () : BoundingBox
163+ public function getBoundingBox (): BoundingBox
156164 {
157165 return array_reduce (
158166 $ this ->curves ,
@@ -165,7 +173,7 @@ public function getBoundingBox() : BoundingBox
165173 * @return list<list<list<float>>>
166174 */
167175 #[Override]
168- public function toArray () : array
176+ public function toArray (): array
169177 {
170178 return array_map (
171179 fn (Curve $ curve ) => $ curve ->toArray (),
@@ -189,7 +197,7 @@ public function project(Projector $projector): CompoundCurve
189197 * Returns the number of curves in this CompoundCurve.
190198 */
191199 #[Override]
192- public function count () : int
200+ public function count (): int
193201 {
194202 return count ($ this ->curves );
195203 }
@@ -200,7 +208,7 @@ public function count() : int
200208 * @return ArrayIterator<int<0, max>, LineString|CircularString>
201209 */
202210 #[Override]
203- public function getIterator () : ArrayIterator
211+ public function getIterator (): ArrayIterator
204212 {
205213 return new ArrayIterator ($ this ->curves );
206214 }
0 commit comments