PhingOptions::setFind()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace BsbPhingService\Options;
4
5
use Zend\Stdlib\AbstractOptions;
6
use Zend\Stdlib\Parameters;
7
8
class PhingOptions extends AbstractOptions
9
{
10
11
    /**
12
     * @var string Path to buildfile
13
     */
14
    private $buildFile;
15
16
    /**
17
     * @var string (optional) Class which is to perform logging
18
     */
19
    private $logger;
20
21
    /**
22
     * @var string (optional) Path to file for logging
23
     */
24
    private $logFile;
25
26
    /**
27
     * @var string (optional) Path to file containing all properties
28
     */
29
    private $propertyFile;
30
31
    /**
32
     * @var Parameters Container of key/values send as properties to phing
33
     */
34
    private $properties;
35
36
    /**
37
     * @var string (optional) class to use to handle user input
38
     */
39
    private $inputHandler;
40
41
    /**
42
     * @var boolean Show target descriptions during build
43
     */
44
    private $longTargets = false;
45
46
    /**
47
     * @var boolean Lists available targets in this project
48
     */
49
    private $list = false;
50
51
    /**
52
     * @var string (optional) Search for a file towards the root of the filesystem and use it as buildfile
53
     */
54
    private $find;
55
56
    /**
57
     * @var bool Be extra quiet
58
     */
59
    private $quiet = false;
60
61
    /**
62
     * @var bool Print debugging information
63
     */
64
    private $debug = false;
65
66
    /**
67
     * @var bool Be extra verbose
68
     */
69
    private $verbose = false;
70
71
    /**
72
     * @param array $options
73
     */
74 18
    public function __construct(array $options = null)
75
    {
76 18
        $this->properties = new Parameters();
77
78 18
        parent::__construct($options);
79 18
    }
80
81
    /**
82
     * @return string
83
     */
84 13
    public function getBuildFile()
85
    {
86 13
        return $this->buildFile;
87
    }
88
89
    /**
90
     * @param string $buildFile
91
     */
92 3
    public function setBuildFile($buildFile)
93
    {
94 3
        $this->buildFile = $buildFile;
95 3
    }
96
97
    /**
98
     * @return string
99
     */
100 13
    public function getLogger()
101
    {
102 13
        return $this->logger;
103
    }
104
105
    /**
106
     * @param string $logger
107
     */
108 1
    public function setLogger($logger)
109
    {
110 1
        $this->logger = $logger;
111 1
    }
112
113
    /**
114
     * @return string
115
     */
116 13
    public function getLogFile()
117
    {
118 13
        return $this->logFile;
119
    }
120
121
    /**
122
     * @param string $logFile
123
     */
124 1
    public function setLogFile($logFile)
125
    {
126 1
        $this->logFile = $logFile;
127 1
    }
128
129
    /**
130
     * @return string
131
     */
132 13
    public function getPropertyFile()
133
    {
134 13
        return $this->propertyFile;
135
    }
136
137
    /**
138
     * @param string $propertyFile
139
     */
140 1
    public function setPropertyFile($propertyFile)
141
    {
142 1
        $this->propertyFile = $propertyFile;
143 1
    }
144
145
    /**
146
     * @return string
147
     */
148 13
    public function getInputHandler()
149
    {
150 13
        return $this->inputHandler;
151
    }
152
153
    /**
154
     * @param string $inputHandler
155
     */
156 1
    public function setInputHandler($inputHandler)
157
    {
158 1
        $this->inputHandler = $inputHandler;
159 1
    }
160
161
    /**
162
     * @return array
163
     */
164 13
    public function getProperties()
165
    {
166 13
        return $this->properties->toArray();
167
    }
168
169
    /**
170
     * @param array $properties
171
     */
172 1
    public function setProperties($properties)
173
    {
174 1
        $this->properties->fromArray($properties);
175
        ;
176 1
    }
177
178
    /**
179
     * @return boolean
180
     */
181 13
    public function isList()
182
    {
183 13
        return $this->list;
184
    }
185
186
    /**
187
     * @param boolean $list
188
     */
189 1
    public function setList($list)
190
    {
191 1
        $this->list = filter_var($list, FILTER_VALIDATE_BOOLEAN);
192 1
    }
193
194
    /**
195
     * @return boolean
196
     */
197 13
    public function isLongTargets()
198
    {
199 13
        return $this->longTargets;
200
    }
201
202
    /**
203
     * @param boolean $longTargets
204
     */
205 1
    public function setLongTargets($longTargets)
206
    {
207 1
        $this->longTargets = filter_var($longTargets, FILTER_VALIDATE_BOOLEAN);
208 1
    }
209
210
    /**
211
     * @return string
212
     */
213 13
    public function getFind()
214
    {
215 13
        return $this->find;
216
    }
217
218
    /**
219
     * @param string $find
220
     */
221 1
    public function setFind($find)
222
    {
223 1
        $this->find = $find;
224 1
    }
225
226
    /**
227
     * @return boolean
228
     */
229 13
    public function isQuiet()
230
    {
231 13
        return $this->quiet;
232
    }
233
234
    /**
235
     * @param boolean $quiet
236
     */
237 1
    public function setQuiet($quiet)
238
    {
239 1
        $this->quiet = filter_var($quiet, FILTER_VALIDATE_BOOLEAN);
240 1
    }
241
242
    /**
243
     * @return boolean
244
     */
245 13
    public function isDebug()
246
    {
247 13
        return $this->debug;
248
    }
249
250
    /**
251
     * @param boolean $debug
252
     */
253 1
    public function setDebug($debug)
254
    {
255 1
        $this->debug = filter_var($debug, FILTER_VALIDATE_BOOLEAN);
256 1
    }
257
258
    /**
259
     * @return boolean
260
     */
261 13
    public function isVerbose()
262
    {
263 13
        return $this->verbose;
264
    }
265
266
    /**
267
     * @param boolean $verbose
268
     */
269 2
    public function setVerbose($verbose)
270
    {
271 2
        $this->verbose = filter_var($verbose, FILTER_VALIDATE_BOOLEAN);
272 2
    }
273
274
    /**
275
     * Construct an array with arguments to configure the phing executable
276
     *
277
     * @return array
278
     */
279 13
    public function toArgumentsArray()
280
    {
281 13
        $arguments = array();
282
283 13
        if ($this->getBuildFile()) {
284 3
            $arguments[] = "-buildfile";
285 3
            $arguments[] = $this->getBuildFile();
286 3
        }
287
288 13
        if ($this->getLogger()) {
289 1
            $arguments[] = "-logger";
290 1
            $arguments[] = $this->getLogger();
291 1
        }
292
293 13
        if ($this->getLogFile()) {
294 1
            $arguments[] = "-logfile";
295 1
            $arguments[] = $this->getLogFile();
296 1
        }
297
298 13
        if ($this->getPropertyFile()) {
299 1
            $arguments[] = "-propertyfile";
300 1
            $arguments[] = $this->getPropertyFile();
301 1
        }
302
303 13
        if ($this->getInputHandler()) {
304 1
            $arguments[] = "-inputhandler";
305 1
            $arguments[] = $this->getInputHandler();
306 1
        }
307
308 13
        if ($this->getFind()) {
309 1
            $arguments[] = "-find";
310 1
            $arguments[] = $this->getFind();
311 1
        }
312
313 13
        if ($this->isLongTargets()) {
314 1
            $arguments[] = "-longtargets";
315 1
        }
316
317 13
        if ($this->isList()) {
318 1
            $arguments[] = "-list";
319 1
        }
320
321 13
        if ($this->isVerbose()) {
322 1
            $arguments[] = "-verbose";
323 1
        }
324
325 13
        if ($this->isDebug()) {
326 1
            $arguments[] = "-debug";
327 1
        }
328
329 13
        if ($this->isQuiet()) {
330 1
            $arguments[] = "-quiet";
331 1
        }
332
333 13
        foreach ($this->getProperties() as $key => $value) {
334 1
            $arguments[] = sprintf("-D%s=%s", (string) $key, (string) $value);
335 13
        }
336
337 13
        return $arguments;
338
    }
339
}
340