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
|
|
|
]; |
27
|
|
|
|
28
|
1 |
|
return new Execute($tools); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return Execute |
33
|
|
|
*/ |
34
|
3 |
|
public static function setUndefined() |
35
|
|
|
{ |
36
|
|
|
$tools = [ |
37
|
3 |
|
ComposerFactory::setUndefined(), |
38
|
3 |
|
JsonLintFactory::setUndefined(), |
39
|
3 |
|
PhpLintFactory::setUndefined(), |
40
|
3 |
|
PhpMdFactory::setUndefined(), |
41
|
3 |
|
PhpCsFactory::setUndefined(), |
42
|
3 |
|
PhpCsFixerFactory::setUndefined(), |
43
|
3 |
|
PhpUnitFactory::setUndefined(), |
44
|
|
|
]; |
45
|
|
|
|
46
|
3 |
|
return new Execute($tools); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|