Passed
Push — master ( afa2e3...eb32d2 )
by Siad
18:11
created

Parameter::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
 * A parameter is composed of a name, type and value. Nested
22
 * Parameters are also possible, but the using task/type has
23
 * to support them
24
 *
25
 * @author  Manuel Holtgrewe
26
 * @author  <a href="mailto:[email protected]">Yannick Lecaillez</a>
27
 * @package phing.types
28
 */
29
class Parameter extends DataType
30
{
31
32
    /**
33
     * Parameter name
34
     */
35
    protected $name;
36
37
    /**
38
     * Parameter type
39
     */
40
    protected $type;
41
42
    /**
43
     * Parameter value
44
     */
45
    protected $value;
46
47
    /**
48
     * Nested parameters
49
     */
50
    protected $parameters = [];
51
52
    /**
53
     * @param $name
54
     */
55 7
    public function setName($name)
56
    {
57 7
        $this->name = (string) $name;
58 7
    }
59
60
    /**
61
     * @param $type
62
     */
63 6
    public function setType($type)
64
    {
65 6
        $this->type = (string) $type;
66 6
    }
67
68
    /**
69
     * Sets value to dynamic register slot.
70
     *
71
     * @param RegisterSlot $value
72
     */
73 1
    public function setListeningValue(RegisterSlot $value)
74
    {
75 1
        $this->value = $value;
76 1
    }
77
78
    /**
79
     * @param $value
80
     */
81 12
    public function setValue($value)
82
    {
83 12
        $this->value = (string) $value;
84 12
    }
85
86
    /**
87
     * @param $v
88
     */
89
    public function addText($v)
90
    {
91
        $this->value = $v;
92
    }
93
94 7
    public function getName()
95
    {
96 7
        return $this->name;
97
    }
98
99 6
    public function getType()
100
    {
101 6
        return $this->type;
102
    }
103
104
    /**
105
     * @return mixed
106
     */
107 13
    public function getValue()
108
    {
109 13
        if ($this->value instanceof RegisterSlot) {
110 1
            return $this->value->getValue();
111
        }
112
113 12
        return $this->value;
114
    }
115
116
    /**
117
     * @return Parameter
118
     */
119 1
    public function createParam()
120
    {
121 1
        $num = array_push($this->parameters, new Parameter());
122
123 1
        return $this->parameters[$num - 1];
124
    }
125
126
    /**
127
     * @return array Nested parameters.
128
     */
129 2
    public function getParams()
130
    {
131 2
        return $this->parameters;
132
    }
133
}
134