Code Duplication    Length = 14-14 lines in 2 locations

math/Vector.php 2 locations

@@ 348-361 (lines=14) @@
345
     * @return  float               The cartesian distance.
346
     * @throws  \DomainException    When the given Vector is not in the same space as this Vector.
347
     */
348
    public function cartesianDistanceTo(Vector $that) : float
349
    {
350
        if (!$this->isSameDimension($that)) {
351
            throw new \DomainException('The given input Vector is not in the same dimension as this Vector.');
352
        }
353
354
        $result = 0;
355
356
        foreach ($this->components as $i => $component) {
357
            $result += pow($component - $that->components[$i], 2);
358
        }
359
360
        return sqrt($result);
361
    }
362
363
    /**
364
     * Returns the Chebyshev (AKA chessboard) distance of this Vector to the given Vector.
@@ 370-383 (lines=14) @@
367
     * @return  float               The taxicab distance.
368
     * @throws  \DomainException    When the given Vector is not in the same space as this Vector.
369
     */
370
    public function chebyshevDistanceTo(Vector $that) : float
371
    {
372
        if (!$this->isSameDimension($that)) {
373
            throw new \DomainException('The given input Vector is not in the same dimension as this Vector.');
374
        }
375
376
        $result = [];
377
378
        foreach ($this->components as $i => $component) {
379
            $result[$i] = abs($component - $that->components[$i]);
380
        }
381
382
        return max($result);
383
    }
384
385
    /**
386
     * Returns the taxicab (AKA Manhattan / city block / rectilinear) distance of this Vector to the given Vector.