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

Collections   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A sort() 0 6 1
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