Completed
Push — master ( 9fb870...82b988 )
by Michiel
18:47
created

CommandlineArgument   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 86.36%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 13
c 2
b 0
f 1
dl 0
loc 78
ccs 19
cts 22
cp 0.8636
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getParts() 0 3 1
A __construct() 0 3 1
A setFile() 0 3 1
A setValue() 0 3 1
A setPath() 0 3 1
A setEscape() 0 3 1
A setLine() 0 6 2
1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19
20
/**
21
 * "Inner" class used for nested xml command line definitions.
22
 *
23
 * @package phing.types
24
 */
25
class CommandlineArgument
26
{
27
    private $parts = [];
28
    private $outer;
29
    public $escape = false;
30
31
    /**
32
     * @param Commandline $outer
33
     */
34 65
    public function __construct(Commandline $outer)
35
    {
36 65
        $this->outer = $outer;
37 65
    }
38
39
    /**
40
     * @param bool $escape
41
     */
42 1
    public function setEscape($escape)
43
    {
44 1
        $this->escape = $escape;
45 1
    }
46
47
    /**
48
     * Sets a single commandline argument.
49
     *
50
     * @param string $value a single commandline argument.
51
     */
52 64
    public function setValue(string $value)
53
    {
54 64
        $this->parts = [$value];
55 64
    }
56
57
    /**
58
     * Line to split into several commandline arguments.
59
     *
60
     * @param  string $line line to split into several commandline arguments
61
     * @throws \BuildException
62
     */
63 11
    public function setLine($line)
64
    {
65 11
        if ($line === null) {
0 ignored issues
show
introduced by
The condition $line === null is always false.
Loading history...
66 1
            return;
67
        }
68 11
        $this->parts = $this->outer::translateCommandline($line);
69 11
    }
70
71
    /**
72
     * Sets a single commandline argument and treats it like a
73
     * PATH - ensures the right separator for the local platform
74
     * is used.
75
     *
76
     * @param Path $value a single commandline argument
77
     */
78
    public function setPath(Path $value): void
79
    {
80
        $this->parts = [(string) $value];
81
    }
82
83
    /**
84
     * Sets a single commandline argument to the absolute filename
85
     * of the given file.
86
     *
87
     * @param    PhingFile $value
88
     * @internal param a $value single commandline argument.
89
     */
90 2
    public function setFile(PhingFile $value): void
91
    {
92 2
        $this->parts = [$value->getAbsolutePath()];
93 2
    }
94
95
    /**
96
     * Returns the parts this Argument consists of.
97
     *
98
     * @return array string[]
99
     */
100 42
    public function getParts(): array
101
    {
102 42
        return $this->parts;
103
    }
104
}
105