Code Duplication    Length = 13-13 lines in 2 locations

src/Map.php 2 locations

@@ 499-511 (lines=13) @@
496
     *
497
     * @param callable|null $comparator Accepts two values to be compared.
498
     */
499
    public function sort(callable $comparator = null)
500
    {
501
        if ($comparator) {
502
            usort($this->internal, function($a, $b) use ($comparator) {
503
                return $comparator($a->value, $b->value);
504
            });
505
506
        } else {
507
            usort($this->internal, function($a, $b) {
508
                return $this->compare($a->value, $b->value);
509
            });
510
        }
511
    }
512
513
    /**
514
     * Returns a sorted copy of the map, based on an optional callable
@@ 546-558 (lines=13) @@
543
     *
544
     * @param callable|null $comparator Accepts two keys to be compared.
545
     */
546
    public function ksort(callable $comparator = null)
547
    {
548
        if ($comparator) {
549
            usort($this->internal, function($a, $b) use ($comparator) {
550
                return $comparator($a->key, $b->key);
551
            });
552
553
        } else {
554
            usort($this->internal, function($a, $b) {
555
                return $this->compare($a->key, $b->key);
556
            });
557
        }
558
    }
559
560
    /**
561
     * Returns a sorted copy of the map, based on an optional callable