Completed
Push — master ( 45600c...8f79c4 )
by Paul
10:17 queued 06:57
created

DefaultConsoleConfigFactory::invokeDir()   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
/**
4
 * This file is part of PHPUnit Generator.
5
 *
6
 * (c) 2017-2018 Paul Thébaud <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhpUnitGen\Configuration;
13
14
use PhpUnitGen\Configuration\ConfigurationInterface\ConsoleConfigInterface;
15
16
/**
17
 * Class DefaultConsoleConfigFactory.
18
 *
19
 * @author     Paul Thébaud <[email protected]>.
20
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
21
 * @license    https://opensource.org/licenses/MIT The MIT license.
22
 * @link       https://github.com/paul-thebaud/phpunit-generator
23
 * @since      Class available since Release 2.0.0.
24
 */
25
class DefaultConsoleConfigFactory
26
{
27
    /**
28
     * Build a console configuration from a configuration file.
29
     *
30
     * @param string $sourceDirectory The source directory.
31
     * @param string $targetDirectory The target directory.
32
     *
33
     * @return ConsoleConfigInterface The created configuration.
34
     */
35
    public function invokeDir(string $sourceDirectory, string $targetDirectory): ConsoleConfigInterface
36
    {
37
        $configArray         = require __DIR__ . '/../../config/default.phpunitgen.config.php';
38
        $configArray['dirs'] = [
39
            $sourceDirectory => $targetDirectory
40
        ];
41
42
        return new ConsoleConfig($configArray);
43
    }
44
45
    /**
46
     * Build a console configuration from a configuration file.
47
     *
48
     * @param string $sourceFile The source file.
49
     * @param string $targetFile The target file.
50
     *
51
     * @return ConsoleConfigInterface The created configuration.
52
     */
53
    public function invokeFile(string $sourceFile, string $targetFile): ConsoleConfigInterface
54
    {
55
        $configArray          = require __DIR__ . '/../../config/default.phpunitgen.config.php';
56
        $configArray['files'] = [
57
            $sourceFile => $targetFile
58
        ];
59
60
        return new ConsoleConfig($configArray);
61
    }
62
}
63