Code Duplication    Length = 13-13 lines in 2 locations

src/Map.php 2 locations

@@ 514-526 (lines=13) @@
511
     *
512
     * @param callable|null $comparator Accepts two values to be compared.
513
     */
514
    public function sort(callable $comparator = null)
515
    {
516
        if ($comparator) {
517
            usort($this->pairs, function($a, $b) use ($comparator) {
518
                return $comparator($a->value, $b->value);
519
            });
520
521
        } else {
522
            usort($this->pairs, function($a, $b) {
523
                return $a->value <=> $b->value;
524
            });
525
        }
526
    }
527
528
    /**
529
     * Returns a sorted copy of the map, based on an optional callable
@@ 561-573 (lines=13) @@
558
     *
559
     * @param callable|null $comparator Accepts two keys to be compared.
560
     */
561
    public function ksort(callable $comparator = null)
562
    {
563
        if ($comparator) {
564
            usort($this->pairs, function($a, $b) use ($comparator) {
565
                return $comparator($a->key, $b->key);
566
            });
567
568
        } else {
569
            usort($this->pairs, function($a, $b) {
570
                return $a->key <=> $b->key;
571
            });
572
        }
573
    }
574
575
    /**
576
     * Returns a sorted copy of the map, based on an optional callable