Completed
Push — master ( 13ee85...192638 )
by Ivannis Suárez
02:46
created

ReverseComparator::acceptComparatorVisitor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
 * Reverse Comparator class.
15
 *
16
 * @author Ivannis Suárez Jerez <[email protected]>
17
 * @author Karel Osorio Ramírez <[email protected]>
18
 */
19
class ReverseComparator extends AbstractComparator
20
{
21
    /**
22
     * @var ComparatorInterface
23
     */
24
    protected $comparator;
25
26
    /**
27
     * Reverse Comparator constructor.
28
     *
29
     * @param ComparatorInterface $comparator
30
     */
31
    public function __construct(ComparatorInterface $comparator)
32
    {
33
        $this->comparator = $comparator;
34
    }
35
36
    /**
37
     * @return \Cubiche\Core\Comparable\ComparatorInterface
38
     */
39
    public function comparator()
40
    {
41
        return $this->comparator;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function compare($a, $b)
48
    {
49
        return -1 * $this->comparator->compare($a, $b);
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function reverse()
56
    {
57
        return $this->comparator();
58
    }
59
}
60