Passed
Pull Request — master (#11)
by
unknown
02:14
created

ShellVariable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A wrapWithBackticks() 0 4 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