ArithmeticExpression::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PHPSu\ShellCommandBuilder\Conditional;
6
7
use PHPSu\ShellCommandBuilder\Definition\ConditionalOperator;
8
use PHPSu\ShellCommandBuilder\ShellInterface;
9
10
final class ArithmeticExpression extends BasicExpression
11
{
12
    public static function create(bool $useBashBrackets = true, bool $negateExpression = false): ArithmeticExpression
13
    {
14
        return new self($useBashBrackets, $negateExpression);
15
    }
16
17
    /**
18
     * @param string|ShellInterface $arg1
19
     * @param string|ShellInterface $arg2
20
     * @return $this
21
     */
22
    public function equal($arg1, $arg2): self
23
    {
24
        $this->operator = ConditionalOperator::ARTITH_EQUAL;
25
        $this->compare = $arg1;
26
        $this->compareWith = $arg2;
27
        return $this;
28
    }
29
30
    /**
31
     * @param string|ShellInterface $arg1
32
     * @param string|ShellInterface $arg2
33
     * @return $this
34
     */
35
    public function notEqual($arg1, $arg2): self
36
    {
37
        $this->operator = ConditionalOperator::ARTITH_NOT_EQUAL;
38
        $this->compare = $arg1;
39
        $this->compareWith = $arg2;
40
        return $this;
41
    }
42
43
    /**
44
     * @param string|ShellInterface $arg1
45
     * @param string|ShellInterface $arg2
46
     * @return $this
47
     */
48
    public function less($arg1, $arg2): self
49
    {
50
        $this->operator = ConditionalOperator::ARTITH_LESS_THAN;
51
        $this->compare = $arg1;
52
        $this->compareWith = $arg2;
53
        return $this;
54
    }
55
56
    /**
57
     * @param string|ShellInterface $arg1
58
     * @param string|ShellInterface $arg2
59
     * @return $this
60
     */
61
    public function greater($arg1, $arg2): self
62
    {
63
        $this->operator = ConditionalOperator::ARTITH_GREATER_THAN;
64
        $this->compare = $arg1;
65
        $this->compareWith = $arg2;
66
        return $this;
67
    }
68
69
    /**
70
     * @param string|ShellInterface $arg1
71
     * @param string|ShellInterface $arg2
72
     * @return $this
73
     */
74
    public function lessEqual($arg1, $arg2): self
75
    {
76
        $this->operator = ConditionalOperator::ARTITH_LESS_EQUAL;
77
        $this->compare = $arg1;
78
        $this->compareWith = $arg2;
79
        return $this;
80
    }
81
82
    /**
83
     * @param string|ShellInterface $arg1
84
     * @param string|ShellInterface $arg2
85
     * @return $this
86
     */
87
    public function greaterEqual($arg1, $arg2): self
88
    {
89
        $this->operator = ConditionalOperator::ARTITH_GREATER_EQUAL;
90
        $this->compare = $arg1;
91
        $this->compareWith = $arg2;
92
        return $this;
93
    }
94
}
95