|
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
|
|
|
namespace Phing\Task\Optional; |
|
21
|
|
|
|
|
22
|
|
|
use Phing\Type\DataType; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Implementation of console argument |
|
26
|
|
|
* |
|
27
|
|
|
* @author nuno costa <[email protected]> |
|
28
|
|
|
* @license GPL |
|
29
|
|
|
* @package phing.tasks.ext.symfony |
|
30
|
|
|
*/ |
|
31
|
|
|
class SymfonyConsoleArg extends DataType |
|
32
|
|
|
{ |
|
33
|
|
|
private $name = null; |
|
34
|
|
|
private $value = null; |
|
35
|
|
|
private $quotes = false; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Gets the argument name |
|
39
|
|
|
* |
|
40
|
|
|
* @return String |
|
41
|
|
|
*/ |
|
42
|
9 |
|
public function getName() |
|
43
|
|
|
{ |
|
44
|
9 |
|
return $this->name; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Sets the argument name |
|
49
|
|
|
* |
|
50
|
|
|
* @param String $name |
|
51
|
|
|
*/ |
|
52
|
7 |
|
public function setName($name) |
|
53
|
|
|
{ |
|
54
|
7 |
|
$this->name = $name; |
|
55
|
7 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Gets the argument value |
|
59
|
|
|
* |
|
60
|
|
|
* @return String |
|
61
|
|
|
*/ |
|
62
|
9 |
|
public function getValue() |
|
63
|
|
|
{ |
|
64
|
9 |
|
return $this->value; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Sets the argument value |
|
69
|
|
|
* |
|
70
|
|
|
* @param String $value |
|
71
|
|
|
*/ |
|
72
|
7 |
|
public function setValue($value) |
|
73
|
|
|
{ |
|
74
|
7 |
|
$this->value = $value; |
|
75
|
7 |
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Should the argument value be enclosed in double quotes |
|
79
|
|
|
* |
|
80
|
|
|
* @return boolean |
|
81
|
|
|
*/ |
|
82
|
9 |
|
public function getQuotes() |
|
83
|
|
|
{ |
|
84
|
9 |
|
return $this->quotes; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Should the argument value be enclosed in double quotes |
|
89
|
|
|
* |
|
90
|
|
|
* @param boolean $quotes |
|
91
|
|
|
*/ |
|
92
|
6 |
|
public function setQuotes($quotes) |
|
93
|
|
|
{ |
|
94
|
6 |
|
$this->quotes = $quotes; |
|
95
|
6 |
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Transforms the argument object into a string, takes into consideration |
|
99
|
|
|
* the quotes and the argument value |
|
100
|
|
|
* |
|
101
|
|
|
* @return String |
|
102
|
|
|
*/ |
|
103
|
8 |
|
public function __toString() |
|
104
|
|
|
{ |
|
105
|
8 |
|
$name = ""; |
|
106
|
8 |
|
$value = ""; |
|
107
|
8 |
|
$quote = $this->getQuotes() ? '"' : ''; |
|
108
|
|
|
|
|
109
|
8 |
|
if (null !== $this->getValue()) { |
|
|
|
|
|
|
110
|
6 |
|
$value = $quote . $this->getValue() . $quote; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
8 |
|
if (null !== $this->getName()) { |
|
|
|
|
|
|
114
|
6 |
|
$name = '--' . $this->getName(); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
8 |
|
if (strlen($name) > 0 && strlen($value) > 0) { |
|
118
|
4 |
|
$value = '=' . $value; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
8 |
|
return $name . $value; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|