Passed
Pull Request — master (#2)
by Sebastian
02:16
created

Collections   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 18
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A sort() 0 7 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
    public static function sort(ArrayList &$list, Comparator $comparator)
23
    {
24
        $array = $list->toArray();
25
        usort($array, [$comparator, "compare"]);
26
        $list->replace($array);
27
        return $list;
28
    }
29
}
30