Completed
Push — master ( 192638...f858f1 )
by Ivannis Suárez
05:02
created

Sort   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A comparator() 0 8 2
A by() 0 4 2
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Core\Comparable;
12
13
/**
14
 * Sort class.
15
 *
16
 * @author Karel Osorio Ramírez <[email protected]>
17
 */
18
class Sort
19
{
20
    /**
21
     * @var ComparatorInterface
22
     */
23
    protected static $comparator = null;
24
25
    /**
26
     * @return \Cubiche\Core\Comparable\ComparatorInterface
27
     */
28
    public static function comparator()
29
    {
30
        if (self::$comparator === null) {
31
            self::$comparator = new Comparator();
32
        }
33
34
        return self::$comparator;
35
    }
36
37
    /**
38
     * @param callable $selector
39
     * @param Order    $order
40
     *
41
     * @return \Cubiche\Core\Comparable\ComparatorInterface
42
     */
43
    public static function by(callable $selector, Order $order = null)
44
    {
45
        return new SelectorComparator($selector, $order === null ? Order::ASC() : $order);
46
    }
47
}
48