Code Duplication    Length = 13-13 lines in 2 locations

src/Map.php 2 locations

@@ 506-518 (lines=13) @@
503
     *
504
     * @param callable|null $comparator Accepts two values to be compared.
505
     */
506
    public function sort(callable $comparator = null)
507
    {
508
        if ($comparator) {
509
            usort($this->pairs, function($a, $b) use ($comparator) {
510
                return $comparator($a->value, $b->value);
511
            });
512
513
        } else {
514
            usort($this->pairs, function($a, $b) {
515
                return $a->value <=> $b->value;
516
            });
517
        }
518
    }
519
520
    /**
521
     * Returns a sorted copy of the map, based on an optional callable
@@ 542-554 (lines=13) @@
539
     *
540
     * @param callable|null $comparator Accepts two keys to be compared.
541
     */
542
    public function ksort(callable $comparator = null)
543
    {
544
        if ($comparator) {
545
            usort($this->pairs, function($a, $b) use ($comparator) {
546
                return $comparator($a->key, $b->key);
547
            });
548
549
        } else {
550
            usort($this->pairs, function($a, $b) {
551
                return $a->key <=> $b->key;
552
            });
553
        }
554
    }
555
556
    /**
557
     * Returns a sorted copy of the map, based on an optional callable