|
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 wrapper for the implementations of PHPUnit2ResultFormatter. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Michiel Rook <[email protected]> |
|
24
|
|
|
* @package phing.tasks.ext.phploc |
|
25
|
|
|
*/ |
|
26
|
|
|
class PHPLocFormatterFactory |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Returns formatter object |
|
30
|
|
|
* |
|
31
|
|
|
* @param PHPLocFormatterElement $formatterElement |
|
32
|
|
|
* @throws BuildException |
|
33
|
|
|
* @return AbstractPHPLocFormatter |
|
34
|
|
|
*/ |
|
35
|
|
|
public static function createFormatter($formatterElement) |
|
36
|
|
|
{ |
|
37
|
|
|
$formatter = null; |
|
38
|
|
|
$type = $formatterElement->getType(); |
|
39
|
|
|
|
|
40
|
|
|
switch ($type) { |
|
41
|
|
|
case "xml": |
|
42
|
|
|
$formatter = new PHPLocXMLFormatter(); |
|
43
|
|
|
break; |
|
44
|
|
|
case "json": |
|
45
|
|
|
$formatter = new PHPLocJSONFormatter(); |
|
46
|
|
|
break; |
|
47
|
|
|
case "csv": |
|
48
|
|
|
$formatter = new PHPLocCSVFormatter(); |
|
49
|
|
|
break; |
|
50
|
|
|
case "txt": |
|
51
|
|
|
case "cli": |
|
52
|
|
|
$formatter = new PHPLocTextFormatter(); |
|
53
|
|
|
break; |
|
54
|
|
|
default: |
|
55
|
|
|
throw new BuildException("Formatter '" . $type . "' not implemented"); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$formatter->setOutfile($formatterElement->getOutfile()); |
|
59
|
|
|
$formatter->setToDir($formatterElement->getToDir()); |
|
60
|
|
|
$formatter->setUseFile($formatterElement->getUseFile()); |
|
61
|
|
|
|
|
62
|
|
|
return $formatter; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|