1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpGitHooks\Module\Configuration\Service; |
4
|
|
|
|
5
|
|
|
use PhpGitHooks\Module\Configuration\Domain\Execute; |
6
|
|
|
use PhpGitHooks\Module\Configuration\Model\ExecuteInterface; |
7
|
|
|
|
8
|
|
|
class PreCommitExecuteFactory |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @param array $data |
12
|
|
|
* |
13
|
|
|
* @return ExecuteInterface |
14
|
|
|
*/ |
15
|
1 |
|
public static function fromArray(array $data) |
16
|
|
|
{ |
17
|
|
|
$tools = [ |
18
|
1 |
|
isset($data['composer']) ? ComposerFactory::fromArray($data['composer']) : ComposerFactory::setUndefined(), |
19
|
1 |
|
isset($data['jsonlint']) ? JsonLintFactory::fromArray($data['jsonlint']) : JsonLintFactory::setUndefined(), |
20
|
1 |
|
isset($data['phplint']) ? PhpLintFactory::fromArray($data['phplint']) : PhpLintFactory::setUndefined(), |
21
|
1 |
|
isset($data['phpmd']) ? PhpMdFactory::fromArray($data['phpmd']) : PhpMdFactory::setUndefined(), |
22
|
1 |
|
isset($data['phpcs']) ? PhpCsFactory::fromArray($data['phpcs']) : PhpCsFactory::setUndefined(), |
23
|
1 |
|
isset($data['php-cs-fixer']) ? PhpCsFixerFactory::fromArray($data['php-cs-fixer']) : |
24
|
1 |
|
PhpCsFixerFactory::setUndefined(), |
25
|
1 |
|
isset($data['phpunit']) ? PhpUnitFactory::fromArray($data['phpunit']) : PhpUnitFactory::setUndefined(), |
26
|
1 |
|
isset($data['phpunit']['strict-coverage']) ? PhpUnitStrictCoverageFactory::fromArray( |
27
|
1 |
|
$data['phpunit']['strict-coverage'] |
28
|
1 |
|
) : PhpUnitStrictCoverageFactory::setUndefined(), |
29
|
1 |
|
isset($data['phpunit']['guard-coverage']) ? PhpUnitGuardCoverageFactory::build( |
30
|
1 |
|
$data['phpunit']['guard-coverage'] |
31
|
1 |
|
) : PhpUnitGuardCoverageFactory::setUndefined(), |
32
|
|
|
]; |
33
|
|
|
|
34
|
1 |
|
return new Execute($tools); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return Execute |
39
|
|
|
*/ |
40
|
3 |
|
public static function setUndefined() |
41
|
|
|
{ |
42
|
|
|
$tools = [ |
43
|
3 |
|
ComposerFactory::setUndefined(), |
44
|
3 |
|
JsonLintFactory::setUndefined(), |
45
|
3 |
|
PhpLintFactory::setUndefined(), |
46
|
3 |
|
PhpMdFactory::setUndefined(), |
47
|
3 |
|
PhpCsFactory::setUndefined(), |
48
|
3 |
|
PhpCsFixerFactory::setUndefined(), |
49
|
3 |
|
PhpUnitFactory::setUndefined(), |
50
|
3 |
|
PhpUnitStrictCoverageFactory::setUndefined(), |
51
|
3 |
|
PhpUnitGuardCoverageFactory::setUndefined(), |
52
|
|
|
]; |
53
|
|
|
|
54
|
3 |
|
return new Execute($tools); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|