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
|
4 |
|
public static function createFormatter($formatterElement) |
36
|
|
|
{ |
37
|
4 |
|
$formatter = null; |
38
|
4 |
|
$type = $formatterElement->getType(); |
39
|
|
|
|
40
|
4 |
|
switch ($type) { |
41
|
4 |
|
case "xml": |
42
|
2 |
|
include_once 'phing/tasks/ext/phploc/PHPLocXMLFormatter.php'; |
43
|
2 |
|
$formatter = new PHPLocXMLFormatter(); |
44
|
2 |
|
break; |
45
|
3 |
|
case "csv": |
46
|
2 |
|
include_once 'phing/tasks/ext/phploc/PHPLocCSVFormatter.php'; |
47
|
2 |
|
$formatter = new PHPLocCSVFormatter(); |
48
|
2 |
|
break; |
49
|
2 |
|
case "txt": |
50
|
|
|
case "cli": |
51
|
2 |
|
include_once 'phing/tasks/ext/phploc/PHPLocTextFormatter.php'; |
52
|
2 |
|
$formatter = new PHPLocTextFormatter(); |
53
|
2 |
|
break; |
54
|
|
|
default: |
55
|
|
|
throw new BuildException("Formatter '" . $type . "' not implemented"); |
56
|
|
|
} |
57
|
|
|
|
58
|
4 |
|
$formatter->setOutfile($formatterElement->getOutfile()); |
59
|
4 |
|
$formatter->setToDir($formatterElement->getToDir()); |
60
|
4 |
|
$formatter->setUseFile($formatterElement->getUseFile()); |
61
|
|
|
|
62
|
4 |
|
return $formatter; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|