RelationalOperator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A comparison() 0 7 1
A comparator() 0 8 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\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