Operator::has()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Fractal\SemVer;
4
5
6
/**
7
 * Class Operator
8
 *
9
 * @author Mikhail Shtanko <[email protected]>
10
 */
11
final class Operator
12
{
13
    /**
14
     * Greater than operator.
15
     *
16
     * @const string
17
     */
18
    public const GREATER = '>';
19
20
    /**
21
     * Greater than or equal to operator.
22
     *
23
     * @const string
24
     */
25
    public const GREATER_OR_EQUAL = '>=';
26
27
    /**
28
     * Less than operator.
29
     *
30
     * @const string
31
     */
32
    public const LESS = '<';
33
34
    /**
35
     * Less than or equal to operator.
36
     *
37
     * @const string
38
     */
39
    public const LESS_OR_EQUAL = '<=';
40
41
    /**
42
     * Equal to operator.
43
     *
44
     * @const string
45
     */
46
    public const EQUAL = '=';
47
48
    /**
49
     * Not equal to operator.
50
     *
51
     * @const string
52
     */
53
    public const NOT_EQUAL = '<>';
54
55
    /**
56
     * Available operators
57
     *
58
     * @var array
59
     */
60
    protected static $operators = [
61
        self::GREATER,
62
        self::GREATER_OR_EQUAL,
63
        self::LESS,
64
        self::LESS_OR_EQUAL,
65
        self::EQUAL,
66
        self::NOT_EQUAL,
67
    ];
68
69
    /**
70
     * Checks operator for availability
71
     *
72
     * @param string $operator
73
     *
74
     * @return bool
75
     */
76 17
    public static function has(string $operator): bool
77
    {
78 17
        return \in_array($operator, static::$operators, true);
79
    }
80
}