ShellArgument::__construct()   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 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
/**
11
 * @internal
12
 * @psalm-internal PHPSu\ShellCommandBuilder
13
 */
14
final class ShellArgument extends ShellWord
15
{
16
    protected $isArgument = true;
17
    protected $delimiter = '';
18
19
    /**
20
     * ShellArgument constructor.
21
     * @param ShellInterface|string $argument
22
     */
23
    public function __construct($argument)
24
    {
25
        parent::__construct('', $argument);
26
    }
27
28
    protected function validate(): void
29
    {
30
        if (is_string($this->value) && empty($this->value)) {
31
            throw new ShellBuilderException('Argument cant be empty');
32
        }
33
        parent::validate();
34
    }
35
}
36