RelationalOperator::comparator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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\Specification\Constraint;
12
13
use Cubiche\Core\Comparable\Comparator;
14
use Cubiche\Core\Comparable\ComparatorInterface;
15
16
/**
17
 * Abstract Relational Operator Class.
18
 *
19
 * @author Karel Osorio Ramírez <[email protected]>
20
 */
21
abstract class RelationalOperator extends BinaryConstraintOperator
22
{
23
    /**
24
     * @var ComparatorInterface
25
     */
26
    private static $comparator = null;
27
28
    /**
29
     * @param mixed $value
30
     *
31
     * @return int
32
     */
33
    protected function comparison($value)
34
    {
35
        return self::comparator()->compare(
36
            $this->left()->apply($value),
37
            $this->right()->apply($value)
38
        );
39
    }
40
41
    /**
42
     * @return \Cubiche\Core\Comparable\ComparatorInterface
43
     */
44
    protected static function comparator()
45
    {
46
        if (self::$comparator === null) {
47
            self::$comparator = new Comparator();
48
        }
49
50
        return self::$comparator;
51
    }
52
}
53