Completed
Push — master ( 908c0b...5086b8 )
by
unknown
23s queued 11s
created

ShellVariable::wrapWithBackticks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PHPSu\ShellCommandBuilder\Literal;
6
7
use PHPSu\ShellCommandBuilder\Exception\ShellBuilderException;
8
use PHPSu\ShellCommandBuilder\ShellInterface;
9
10
final class ShellVariable extends ShellWord
11
{
12
    protected $isVariable = true;
13
    protected $useAssignOperator = true;
14
    protected $wrapAsSubcommand = true;
15
    protected $spaceAfterValue = false;
16
17
    /**
18
     * ShellVariable constructor.
19
     * @param string $option
20
     * @param ShellInterface|string $value
21
     * @throws ShellBuilderException
22
     */
23
    public function __construct(string $option, $value)
24
    {
25
        parent::__construct($option, $value);
26
        if ($this->value instanceof ShellInterface) {
27
            $this->setEscape(false);
28
        }
29
    }
30
31
    public function wrapWithBackticks(bool $enable): self
32
    {
33
        $this->wrapWithBacktricks = $enable;
34
        return $this;
35
    }
36
}
37