Completed
Push — master ( e1c388...7bf58d )
by
unknown
12:55 queued 10:58
created

ShellList::async()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
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\Collection;
6
7
use PHPSu\ShellCommandBuilder\Definition\ControlOperator;
8
use PHPSu\ShellCommandBuilder\Exception\ShellBuilderException;
9
use PHPSu\ShellCommandBuilder\ShellInterface;
10
11
final class ShellList extends AbstractCollection
12
{
13
    /**
14
     * Returns something like: || echo "hello world"
15
     *
16
     * @param string|ShellInterface $command
17
     * @return $this
18
     * @throws ShellBuilderException
19
     */
20
    public static function addOr($command): self
21
    {
22
        $list = new self();
23
        $list->tuple = $list->toTuple($command, ControlOperator::OR_OPERATOR);
24
        return $list;
25
    }
26
27
    /**
28
     * Returns something like: && echo "hello world"
29
     *
30
     * @param string|ShellInterface $command
31
     * @return $this
32
     * @throws ShellBuilderException
33
     */
34
    public static function addAnd($command): self
35
    {
36
        $list = new self();
37
        $list->tuple = $list->toTuple($command, ControlOperator::AND_OPERATOR);
38
        return $list;
39
    }
40
41
    /**
42
     * Returns something like: ; echo "hello world"
43
     *
44
     * @param string|ShellInterface $command
45
     * @return $this
46
     * @throws ShellBuilderException
47
     */
48
    public static function add($command): self
49
    {
50
        $list = new self();
51
        $list->tuple = $list->toTuple($command, ControlOperator::COMMAND_DELIMITER);
52
        return $list;
53
    }
54
55
    /**
56
     * Returns something like: & echo "hello world"
57
     *
58
     * @param string|ShellInterface $command
59
     * @return static
60
     * @throws ShellBuilderException
61
     */
62
    public static function async($command): self
63
    {
64
        $list = new self();
65
        $list->tuple = $list->toTuple($command, ControlOperator::BASH_AMPERSAND);
66
        return $list;
67
    }
68
}
69