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
 * Implementation of console argument
22
 *
23
 * @author  nuno costa <nuno@francodacosta.com>
24
 * @license GPL
25
 * @package phing.tasks.ext.symfony
26
 */
27
class Arg extends DataType
28
{
29
    private $name = null;
30
    private $value = null;
31
    private $quotes = false;
32

33
    /**
34
     * Gets the argument name
35
     *
36
     * @return String
37
     */
38 1
    public function getName()
39
    {
40 1
        return $this->name;
41
    }
42

43
    /**
44
     * Sets the argument name
45
     *
46
     * @param String $name
47
     */
48 1
    public function setName($name)
49
    {
50 1
        $this->name = $name;
51
    }
52

53
    /**
54
     * Gets the argument value
55
     *
56
     * @return String
57
     */
58 1
    public function getValue()
59
    {
60 1
        return $this->value;
61
    }
62

63
    /**
64
     * Sets the argument value
65
     *
66
     * @param String $value
67
     */
68 1
    public function setValue($value)
69
    {
70 1
        $this->value = $value;
71
    }
72

73
    /**
74
     * Should the argument value be enclosed in double quotes
75
     *
76
     * @return boolean
77
     */
78 1
    public function getQuotes()
79
    {
80 1
        return $this->quotes;
81
    }
82

83
    /**
84
     * Should the argument value be enclosed in double quotes
85
     *
86
     * @param boolean $quotes
87
     */
88 1
    public function setQuotes($quotes)
89
    {
90 1
        $this->quotes = $quotes;
91
    }
92

93
    /**
94
     * Transforms the argument object into a string, takes into consideration
95
     * the quotes and the argument value
96
     *
97
     * @return String
98
     */
99 1
    public function __toString()
100
    {
101 1
        $name = "";
102 1
        $value = "";
103 1
        $quote = $this->getQuotes() ? '"' : '';
104

105 1
        if (null !== $this->getValue()) {
106 1
            $value = $quote . $this->getValue() . $quote;
107
        }
108

109 1
        if (null !== $this->getName()) {
110 1
            $name = '--' . $this->getName();
111
        }
112

113 1
        if (strlen($name) > 0 && strlen($value) > 0) {
114 1
            $value = '=' . $value;
115
        }
116

117 1
        return $name . $value;
118
    }
119
}

Read our documentation on viewing source code .

Loading