Completed
Push — master ( 7bf58d...9f8ca5 )
by
unknown
20s queued 12s
created

ShellExpression   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 1
b 0
f 0
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A isVariableSetWithNamedReference() 0 5 1
A isOptnameEnabled() 0 5 1
A isVariableSet() 0 5 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