Code Duplication    Length = 17-17 lines in 2 locations

src/Map.php 2 locations

@@ 529-545 (lines=17) @@
526
     *
527
     * @return Map
528
     */
529
    public function sort(callable $comparator = null): Map
530
    {
531
        $sorted = new self($this);
532
533
        if ($comparator) {
534
            usort($sorted->pairs, function($a, $b) use ($comparator) {
535
                return $comparator($a->value, $b->value);
536
            });
537
538
        } else {
539
            usort($sorted->pairs, function($a, $b) {
540
                return $a->value <=> $b->value;
541
            });
542
        }
543
544
        return $sorted;
545
    }
546
547
    /**
548
     * Returns a sorted copy of the map, based on an optional callable
@@ 555-571 (lines=17) @@
552
     *
553
     * @return Map
554
     */
555
    public function ksort(callable $comparator = null): Map
556
    {
557
        $sorted = clone $this;
558
559
        if ($comparator) {
560
            usort($sorted->pairs, function($a, $b) use ($comparator) {
561
                return $comparator($a->key, $b->key);
562
            });
563
564
        } else {
565
            usort($sorted->pairs, function($a, $b) {
566
                return $a->key <=> $b->key;
567
            });
568
        }
569
570
        return $sorted;
571
    }
572
573
    /**
574
     * @inheritDoc