Passed
Branch version-1.x (4225f6)
by Sebastian
02:41 queued 58s
created

Collections::sort()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Seboettg\Collection;
4
5
6
/**
7
 * Class Collections
8
 * @package Seboettg\Collection
9
 *
10
 * @author Sebastian Böttger <[email protected]>
11
 */
12
class Collections
13
{
14
    /**
15
     * Sorts the specified list according to the order induced by the specified comparator. All elements in the list
16
     * must be mutually comparable.
17
     *
18
     * @param ArrayList $list
19
     * @param Comparator $comparator
20
     * @return ArrayList
21
     */
22 2
    public static function sort(ArrayList &$list, Comparator $comparator)
23
    {
24 2
        $array = $list->toArray();
25 2
        usort($array, [$comparator, "compare"]);
26 2
        $list->replace($array);
27 2
        return $list;
28
    }
29
}
30