ShellExpression::isVariableSet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
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 ShellExpression extends BasicExpression
11
{
12
    protected $escapedValue = true;
13
14
    public static function create(bool $useBashBrackets = true, bool $negateExpression = false): ShellExpression
15
    {
16
        return new self($useBashBrackets, $negateExpression);
17
    }
18
19
    /**
20
     * @param string|ShellInterface $optname
21
     * @return $this
22
     */
23
    public function isOptnameEnabled($optname): self
24
    {
25
        $this->operator = ConditionalOperator::SHELL_OPTNAME_ENABLED;
26
        $this->compareWith = $optname;
27
        return $this;
28
    }
29
30
    /**
31
     * @param string|ShellInterface $variable
32
     * @return $this
33
     */
34
    public function isVariableSet($variable): self
35
    {
36
        $this->operator = ConditionalOperator::SHELL_VARNAME_SET;
37
        $this->compareWith = $variable;
38
        return $this;
39
    }
40
41
    /**
42
     * @param string|ShellInterface $variable
43
     * @return $this
44
     */
45
    public function isVariableSetWithNamedReference($variable): self
46
    {
47
        $this->operator = ConditionalOperator::SHELL_VARNAME_SET_NAMED_REFERENCE;
48
        $this->compareWith = $variable;
49
        return $this;
50
    }
51
}
52