| Total Complexity | 63 |
| Total Lines | 527 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Complex classes like GEOSGeometry often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use GEOSGeometry, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 11 | class GEOSGeometry |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * This method is actually public, but throws a fatal error. |
||
| 15 | * |
||
| 16 | * GEOSGeometry can't be constructed using new, check WKTReader. |
||
| 17 | */ |
||
| 18 | private function __construct() {} |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @return string |
||
| 22 | */ |
||
| 23 | public function __toString() {} |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param GEOSGeometry $other |
||
| 27 | * @param bool $normalized |
||
| 28 | * |
||
| 29 | * @return float |
||
| 30 | * |
||
| 31 | * @throws \Exception |
||
| 32 | */ |
||
| 33 | public function project(GEOSGeometry $other, $normalized = false) {} |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param float $dist |
||
| 37 | * @param bool $normalized |
||
| 38 | * |
||
| 39 | * @return GEOSGeometry |
||
| 40 | * |
||
| 41 | * @throws \Exception |
||
| 42 | */ |
||
| 43 | public function interpolate($dist, $normalized = false) {} |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param float $dist |
||
| 47 | * @param array{quad_segs?:int|float,join?:int,endcap?:int,mitre_limit?:int|float} $styleArray |
||
| 48 | * |
||
| 49 | * @return GEOSGeometry |
||
| 50 | * |
||
| 51 | * @throws \Exception |
||
| 52 | */ |
||
| 53 | public function buffer($dist, array $styleArray = []) {} |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param float $dist |
||
| 57 | * @param array{quad_segs?:int|float,join?:int,mitre_limit?:int|float} $styleArray |
||
| 58 | * |
||
| 59 | * @return GEOSGeometry |
||
| 60 | * |
||
| 61 | * @throws \Exception |
||
| 62 | */ |
||
| 63 | public function offsetCurve($dist, array $styleArray = []) {} |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @return GEOSGeometry |
||
| 67 | * |
||
| 68 | * @throws \Exception |
||
| 69 | */ |
||
| 70 | public function envelope() {} |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param GEOSGeometry $geom |
||
| 74 | * |
||
| 75 | * @return GEOSGeometry |
||
| 76 | * |
||
| 77 | * @throws \Exception |
||
| 78 | */ |
||
| 79 | public function intersection(GEOSGeometry $geom) {} |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return GEOSGeometry |
||
| 83 | * |
||
| 84 | * @throws \Exception |
||
| 85 | */ |
||
| 86 | public function convexHull() {} |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param GEOSGeometry $geom |
||
| 90 | * |
||
| 91 | * @return GEOSGeometry |
||
| 92 | * |
||
| 93 | * @throws \Exception |
||
| 94 | */ |
||
| 95 | public function difference(GEOSGeometry $geom) {} |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param GEOSGeometry $geom |
||
| 99 | * |
||
| 100 | * @return GEOSGeometry |
||
| 101 | * |
||
| 102 | * @throws \Exception |
||
| 103 | */ |
||
| 104 | public function symDifference(GEOSGeometry $geom) {} |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @return GEOSGeometry |
||
| 108 | * |
||
| 109 | * @throws \Exception |
||
| 110 | */ |
||
| 111 | public function boundary() {} |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @param GEOSGeometry $otherGeom Optional, but explicit NULL is not allowed. |
||
| 115 | * |
||
| 116 | * @return GEOSGeometry |
||
| 117 | * |
||
| 118 | * @throws \Exception |
||
| 119 | */ |
||
| 120 | public function union(GEOSGeometry $otherGeom = null) {} |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @return GEOSGeometry |
||
| 124 | * |
||
| 125 | * @throws \Exception |
||
| 126 | */ |
||
| 127 | public function pointOnSurface() {} |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @return GEOSGeometry |
||
| 131 | * |
||
| 132 | * @throws \Exception |
||
| 133 | */ |
||
| 134 | public function centroid() {} |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @param GEOSGeometry $otherGeom |
||
| 138 | * @param string $pattern |
||
| 139 | * |
||
| 140 | * @return string|bool String if pattern is omitted, boolean if pattern is set. |
||
| 141 | * |
||
| 142 | * @throws \Exception |
||
| 143 | */ |
||
| 144 | public function relate(GEOSGeometry $otherGeom, $pattern = '') {} |
||
| 145 | |||
| 146 | /** |
||
| 147 | * @param GEOSGeometry $otherGeom |
||
| 148 | * @param int $rule |
||
| 149 | * |
||
| 150 | * @return string |
||
| 151 | * |
||
| 152 | * @throws \Exception |
||
| 153 | */ |
||
| 154 | public function relateBoundaryNodeRule(GEOSGeometry $otherGeom, $rule) {} |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @param float $tolerance |
||
| 158 | * @param bool $preserveTopology |
||
| 159 | * |
||
| 160 | * @return GEOSGeometry |
||
| 161 | * |
||
| 162 | * @throws \Exception |
||
| 163 | */ |
||
| 164 | public function simplify($tolerance, $preserveTopology = false) {} |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @return GEOSGeometry |
||
| 168 | * |
||
| 169 | * @throws \Exception |
||
| 170 | */ |
||
| 171 | public function normalize() {} |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @return GEOSGeometry |
||
| 175 | * |
||
| 176 | * @throws \Exception |
||
| 177 | */ |
||
| 178 | public function extractUniquePoints() {} |
||
| 179 | |||
| 180 | /** |
||
| 181 | * @param GEOSGeometry $geom |
||
| 182 | * |
||
| 183 | * @return bool |
||
| 184 | * |
||
| 185 | * @throws \Exception |
||
| 186 | */ |
||
| 187 | public function disjoint(GEOSGeometry $geom) {} |
||
| 188 | |||
| 189 | /** |
||
| 190 | * @param GEOSGeometry $geom |
||
| 191 | * |
||
| 192 | * @return bool |
||
| 193 | * |
||
| 194 | * @throws \Exception |
||
| 195 | */ |
||
| 196 | public function touches(GEOSGeometry $geom) {} |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @param GEOSGeometry $geom |
||
| 200 | * |
||
| 201 | * @return bool |
||
| 202 | * |
||
| 203 | * @throws \Exception |
||
| 204 | */ |
||
| 205 | public function intersects(GEOSGeometry $geom) {} |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @param GEOSGeometry $geom |
||
| 209 | * |
||
| 210 | * @return bool |
||
| 211 | * |
||
| 212 | * @throws \Exception |
||
| 213 | */ |
||
| 214 | public function crosses(GEOSGeometry $geom) {} |
||
| 215 | |||
| 216 | /** |
||
| 217 | * @param GEOSGeometry $geom |
||
| 218 | * |
||
| 219 | * @return bool |
||
| 220 | * |
||
| 221 | * @throws \Exception |
||
| 222 | */ |
||
| 223 | public function within(GEOSGeometry $geom) {} |
||
| 224 | |||
| 225 | /** |
||
| 226 | * @param GEOSGeometry $geom |
||
| 227 | * |
||
| 228 | * @return bool |
||
| 229 | * |
||
| 230 | * @throws \Exception |
||
| 231 | */ |
||
| 232 | public function contains(GEOSGeometry $geom) {} |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @param GEOSGeometry $geom |
||
| 236 | * |
||
| 237 | * @return bool |
||
| 238 | * |
||
| 239 | * @throws \Exception |
||
| 240 | */ |
||
| 241 | public function overlaps(GEOSGeometry $geom) {} |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @param GEOSGeometry $geom |
||
| 245 | * |
||
| 246 | * @return bool |
||
| 247 | * |
||
| 248 | * @throws \Exception |
||
| 249 | */ |
||
| 250 | public function covers(GEOSGeometry $geom) {} |
||
| 251 | |||
| 252 | /** |
||
| 253 | * @param GEOSGeometry $geom |
||
| 254 | * |
||
| 255 | * @return bool |
||
| 256 | * |
||
| 257 | * @throws \Exception |
||
| 258 | */ |
||
| 259 | public function coveredBy(GEOSGeometry $geom) {} |
||
| 260 | |||
| 261 | /** |
||
| 262 | * @param GEOSGeometry $geom |
||
| 263 | * |
||
| 264 | * @return bool |
||
| 265 | * |
||
| 266 | * @throws \Exception |
||
| 267 | */ |
||
| 268 | public function equals(GEOSGeometry $geom) {} |
||
| 269 | |||
| 270 | /** |
||
| 271 | * @param GEOSGeometry $geom |
||
| 272 | * @param float $tolerance |
||
| 273 | * |
||
| 274 | * @return bool |
||
| 275 | * |
||
| 276 | * @throws \Exception |
||
| 277 | */ |
||
| 278 | public function equalsExact(GEOSGeometry $geom, $tolerance = 0.0) {} |
||
| 279 | |||
| 280 | /** |
||
| 281 | * @return bool |
||
| 282 | * |
||
| 283 | * @throws \Exception |
||
| 284 | */ |
||
| 285 | public function isEmpty() {} |
||
| 286 | |||
| 287 | /** |
||
| 288 | * Returns information about the validity of this geometry. |
||
| 289 | * |
||
| 290 | * The result is an associative array containing the following keys: |
||
| 291 | * |
||
| 292 | * | Key name | Type | Presence | Description | |
||
| 293 | * |------------|--------------|----------|-------------------------------------------------| |
||
| 294 | * | 'valid' | boolean | Always | True if the geometry is valid, False otherwise. | |
||
| 295 | * | 'reason' | string | Optional | A reason for invalidity. | |
||
| 296 | * | 'location' | GEOSGeometry | Optional | The failing geometry. | |
||
| 297 | * |
||
| 298 | * @return array{"valid":bool,"reason"?:string,"location"?:GEOSGeometry} |
||
| 299 | * |
||
| 300 | * @throws \Exception |
||
| 301 | */ |
||
| 302 | public function checkValidity() {} |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @return bool |
||
| 306 | * |
||
| 307 | * @throws \Exception |
||
| 308 | */ |
||
| 309 | public function isSimple() {} |
||
| 310 | |||
| 311 | /** |
||
| 312 | * @return bool |
||
| 313 | * |
||
| 314 | * @throws \Exception |
||
| 315 | */ |
||
| 316 | public function isRing() {} |
||
| 317 | |||
| 318 | /** |
||
| 319 | * @return bool |
||
| 320 | * |
||
| 321 | * @throws \Exception |
||
| 322 | */ |
||
| 323 | public function hasZ() {} |
||
| 324 | |||
| 325 | /** |
||
| 326 | * @return bool |
||
| 327 | * |
||
| 328 | * @throws \Exception On error, e.g. if this geometry is not a LineString. |
||
| 329 | */ |
||
| 330 | public function isClosed() {} |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @return string |
||
| 334 | * |
||
| 335 | * @throws \Exception |
||
| 336 | */ |
||
| 337 | public function typeName() {} |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @return int |
||
| 341 | * |
||
| 342 | * @throws \Exception |
||
| 343 | */ |
||
| 344 | public function typeId() {} |
||
| 345 | |||
| 346 | /** |
||
| 347 | * @return int |
||
| 348 | * |
||
| 349 | * @throws \Exception |
||
| 350 | */ |
||
| 351 | public function getSRID() {} |
||
| 352 | |||
| 353 | /** |
||
| 354 | * @param int $srid |
||
| 355 | * |
||
| 356 | * @return void |
||
| 357 | * |
||
| 358 | * @throws \Exception |
||
| 359 | */ |
||
| 360 | public function setSRID($srid) {} |
||
| 361 | |||
| 362 | /** |
||
| 363 | * @return int |
||
| 364 | * |
||
| 365 | * @throws \Exception |
||
| 366 | */ |
||
| 367 | public function numGeometries() {} |
||
| 368 | |||
| 369 | /** |
||
| 370 | * @param int $num |
||
| 371 | * |
||
| 372 | * @return GEOSGeometry |
||
| 373 | * |
||
| 374 | * @throws \Exception |
||
| 375 | */ |
||
| 376 | public function geometryN($num) {} |
||
| 377 | |||
| 378 | /** |
||
| 379 | * @return int |
||
| 380 | * |
||
| 381 | * @throws \Exception |
||
| 382 | */ |
||
| 383 | public function numInteriorRings() {} |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @return int |
||
| 387 | * |
||
| 388 | * @throws \Exception |
||
| 389 | */ |
||
| 390 | public function numPoints() {} |
||
| 391 | |||
| 392 | /** |
||
| 393 | * @return float |
||
| 394 | * |
||
| 395 | * @throws \Exception |
||
| 396 | */ |
||
| 397 | public function getX() {} |
||
| 398 | |||
| 399 | /** |
||
| 400 | * @return float |
||
| 401 | * |
||
| 402 | * @throws \Exception |
||
| 403 | */ |
||
| 404 | public function getY() {} |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @param int $num |
||
| 408 | * |
||
| 409 | * @return GEOSGeometry |
||
| 410 | * |
||
| 411 | * @throws \Exception |
||
| 412 | */ |
||
| 413 | public function interiorRingN($num) {} |
||
| 414 | |||
| 415 | /** |
||
| 416 | * @return GEOSGeometry |
||
| 417 | * |
||
| 418 | * @throws \Exception |
||
| 419 | */ |
||
| 420 | public function exteriorRing() {} |
||
| 421 | |||
| 422 | /** |
||
| 423 | * @return int |
||
| 424 | * |
||
| 425 | * @throws \Exception |
||
| 426 | */ |
||
| 427 | public function numCoordinates() {} |
||
| 428 | |||
| 429 | /** |
||
| 430 | * @return int |
||
| 431 | * |
||
| 432 | * @throws \Exception |
||
| 433 | */ |
||
| 434 | public function dimension() {} |
||
| 435 | |||
| 436 | /** |
||
| 437 | * @return int |
||
| 438 | * |
||
| 439 | * @throws \Exception |
||
| 440 | */ |
||
| 441 | public function coordinateDimension() {} |
||
| 442 | |||
| 443 | /** |
||
| 444 | * @param int $num |
||
| 445 | * |
||
| 446 | * @return GEOSGeometry |
||
| 447 | * |
||
| 448 | * @throws \Exception |
||
| 449 | */ |
||
| 450 | public function pointN($num) {} |
||
| 451 | |||
| 452 | /** |
||
| 453 | * @return GEOSGeometry |
||
| 454 | * |
||
| 455 | * @throws \Exception |
||
| 456 | */ |
||
| 457 | public function startPoint() {} |
||
| 458 | |||
| 459 | /** |
||
| 460 | * @return GEOSGeometry |
||
| 461 | * |
||
| 462 | * @throws \Exception |
||
| 463 | */ |
||
| 464 | public function endPoint() {} |
||
| 465 | |||
| 466 | /** |
||
| 467 | * @return float |
||
| 468 | * |
||
| 469 | * @throws \Exception |
||
| 470 | */ |
||
| 471 | public function area() {} |
||
| 472 | |||
| 473 | /** |
||
| 474 | * @return float |
||
| 475 | * |
||
| 476 | * @throws \Exception |
||
| 477 | */ |
||
| 478 | public function length() {} |
||
| 479 | |||
| 480 | /** |
||
| 481 | * @param GEOSGeometry $geom |
||
| 482 | * |
||
| 483 | * @return float |
||
| 484 | * |
||
| 485 | * @throws \Exception |
||
| 486 | */ |
||
| 487 | public function distance(GEOSGeometry $geom) {} |
||
| 488 | |||
| 489 | /** |
||
| 490 | * @param GEOSGeometry $geom |
||
| 491 | * |
||
| 492 | * @return float |
||
| 493 | * |
||
| 494 | * @throws \Exception |
||
| 495 | */ |
||
| 496 | public function hausdorffDistance(GEOSGeometry $geom) {} |
||
| 497 | |||
| 498 | /** |
||
| 499 | * @param GEOSGeometry $geom |
||
| 500 | * @param float $tolerance |
||
| 501 | * |
||
| 502 | * @return GEOSGeometry |
||
| 503 | * |
||
| 504 | * @throws \Exception |
||
| 505 | */ |
||
| 506 | public function snapTo(GEOSGeometry $geom, $tolerance) {} |
||
| 507 | |||
| 508 | /** |
||
| 509 | * @return GEOSGeometry |
||
| 510 | * |
||
| 511 | * @throws \Exception |
||
| 512 | */ |
||
| 513 | public function node() {} |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @param float $tolerance Snapping tolerance to use for improved robustness. |
||
| 517 | * @param bool $onlyEdges If true will return a MULTILINESTRING, otherwise (the default) |
||
| 518 | * it will return a GEOMETRYCOLLECTION containing triangular POLYGONs. |
||
| 519 | * |
||
| 520 | * @return GEOSGeometry |
||
| 521 | * |
||
| 522 | * @throws \Exception |
||
| 523 | */ |
||
| 524 | public function delaunayTriangulation($tolerance = 0.0, $onlyEdges = false) {} |
||
| 525 | |||
| 526 | /** |
||
| 527 | * @param float $tolerance Snapping tolerance to use for improved robustness. |
||
| 528 | * @param bool $onlyEdges If true will return a MULTILINESTRING, otherwise (the default) |
||
| 529 | * it will return a GEOMETRYCOLLECTION containing POLYGONs. |
||
| 530 | * @param GEOSGeometry $extent Clip returned diagram by the extent of the given geometry. |
||
| 531 | * Optional, but explicit NULL value is not allowed. |
||
| 532 | * |
||
| 533 | * @return GEOSGeometry |
||
| 534 | * |
||
| 535 | * @throws \Exception |
||
| 536 | */ |
||
| 537 | public function voronoiDiagram($tolerance = 0.0, $onlyEdges = false, GEOSGeometry $extent = null) {} |
||
| 538 | } |
||
| 539 |