Completed
Push — develop ( 9a283c...250195 )
by Paul
02:08
created

DefaultConsoleConfigFactory::invokeFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Configuration;
4
5
use PhpUnitGen\Configuration\ConfigurationInterface\ConsoleConfigInterface;
6
7
/**
8
 * Class DefaultConsoleConfigFactory.
9
 *
10
 * @author     Paul Thébaud <[email protected]>.
11
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
12
 * @license    https://opensource.org/licenses/MIT The MIT license.
13
 * @link       https://github.com/paul-thebaud/phpunit-generator
14
 * @since      Class available since Release 2.0.0.
15
 */
16
class DefaultConsoleConfigFactory
17
{
18
    /**
19
     * Build a console configuration from a configuration file.
20
     *
21
     * @param string $sourceDirectory The source directory.
22
     * @param string $targetDirectory The target directory.
23
     *
24
     * @return ConsoleConfigInterface The created configuration.
25
     */
26
    public function invokeDir(string $sourceDirectory, string $targetDirectory): ConsoleConfigInterface
27
    {
28
        $configArray         = require __DIR__ . '/../../config/default.phpunitgen.config.php';
29
        $configArray['dirs'] = [
30
            $sourceDirectory => $targetDirectory
31
        ];
32
33
        return new ConsoleConfig($configArray);
34
    }
35
36
    /**
37
     * Build a console configuration from a configuration file.
38
     *
39
     * @param string $sourceFile The source file.
40
     * @param string $targetFile The target file.
41
     *
42
     * @return ConsoleConfigInterface The created configuration.
43
     */
44
    public function invokeFile(string $sourceFile, string $targetFile): ConsoleConfigInterface
45
    {
46
        $configArray          = require __DIR__ . '/../../config/default.phpunitgen.config.php';
47
        $configArray['files'] = [
48
            $sourceFile => $targetFile
49
        ];
50
51
        return new ConsoleConfig($configArray);
52
    }
53
}
54