DataSetLoaderFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 1 Features 2
Metric Value
wmc 4
c 7
b 1
f 2
lcom 0
cbo 3
dl 0
loc 49
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A YAML() 0 10 2
A XML() 0 12 2
1
<?php namespace BuildR\TestTools\DataSetLoader;
2
3
use BuildR\TestTools\DataSetLoader\XML\Parser\XMLDefinitionParserInterface;
4
use BuildR\TestTools\DataSetLoader\XML\XMLDataSetLoader;
5
use BuildR\TestTools\DataSetLoader\YAML\Parser\YAMLParserInterface;
6
use BuildR\TestTools\DataSetLoader\YAML\YAMLDataSetLoader;
7
8
/**
9
 * DataSetParser Factory
10
 *
11
 * BuildR PHP Framework
12
 *
13
 * @author Zoltán Borsos <[email protected]>
14
 * @package TestTools
15
 * @subpackage DataSetLoader
16
 *
17
 * @copyright    Copyright 2016, Zoltán Borsos.
18
 * @license      https://github.com/BuildrPHP/Test-Tools/blob/master/LICENSE.md
19
 * @link         https://github.com/BuildrPHP/Test-Tools
20
 */
21
class DataSetLoaderFactory {
22
23
    /**
24
     * Creates a new YAML dataSet parser
25
     *
26
     * @param string $fileLocation File absolute location
27
     * @param string|NULL $dataSetName The name of the loaded dataSet If not provided, the first dataSet will be used.
28
     * @param \BuildR\TestTools\DataSetLoader\YAML\Parser\YAMLParserInterface|NULL $parser
29
     *
30
     * @return \BuildR\TestTools\DataSetLoader\YAML\YAMLDataSetLoader
31
     */
32
    //@codingStandardIgnoreStart
33 4
    public static function YAML($fileLocation, $dataSetName = NULL, YAMLParserInterface $parser = NULL) {
34
    //@codingStandardIgnoreEnd
35 4
        $loader = new YAMLDataSetLoader($fileLocation, $parser);
36
37 4
        if($dataSetName !== NULL) {
38 1
            $loader->setDataSet($dataSetName);
39 1
        }
40
41 4
        return $loader;
42
    }
43
44
    /**
45
     * Creates a new XML dateSet parser
46
     *
47
     * @param string $fileLocation Input file absolute location
48
     * @param string|NULL $dataSetName The name of the loaded dataSet If not provided, the first dataSet will be used.
49
     * @param \BuildR\TestTools\DataSetLoader\XML\Parser\XMLDefinitionParserInterface|NULL $parser
50
     *
51
     * @return \BuildR\TestTools\DataSetLoader\XML\XMLDataSetLoader
52
     *
53
     * @codingStandardsIgnoreLine
54
     */
55
    //@codingStandardIgnoreStart
56 5
    public static function XML($fileLocation, $dataSetName = NULL, XMLDefinitionParserInterface $parser = NULL) {
57
    //@codingStandardIgnoreEnd
58 5
        $loader = new XMLDataSetLoader($fileLocation, $parser);
59
60 5
        if($dataSetName !== NULL) {
61
            /** @type \BuildR\TestTools\DataSetLoader\XML\Parser\StandardXMLDefinitionParser $parser */
62 3
            $parser = $loader->getParser();
63 3
            $parser->setTestGroup($dataSetName);
64 3
        }
65
66 5
        return $loader;
67
    }
68
69
}
70