|
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
|
|
|
|