@@ 9-38 (lines=30) @@ | ||
6 | use PhpGitHooks\Module\Configuration\Domain\PreCommit; |
|
7 | use PhpGitHooks\Module\Configuration\Domain\Undefined; |
|
8 | ||
9 | class PreCommitFactory |
|
10 | { |
|
11 | /** |
|
12 | * @param array $data |
|
13 | * |
|
14 | * @return PreCommit |
|
15 | */ |
|
16 | public static function fromArray(array $data) |
|
17 | { |
|
18 | return new PreCommit( |
|
19 | new Undefined(false), |
|
20 | new Enabled($data['enabled']), |
|
21 | PreCommitExecuteFactory::fromArray($data['process']), |
|
22 | isset($data['messages']) ? MessagesFactory::fromArray($data['messages']) : MessagesFactory::setUndefined() |
|
23 | ); |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * @return PreCommit |
|
28 | */ |
|
29 | public static function setUndefined() |
|
30 | { |
|
31 | return new PreCommit( |
|
32 | new Undefined(true), |
|
33 | new Enabled(false), |
|
34 | PreCommitExecuteFactory::setUndefined(), |
|
35 | MessagesFactory::setUndefined() |
|
36 | ); |
|
37 | } |
|
38 | } |
|
39 |
@@ 9-38 (lines=30) @@ | ||
6 | use PhpGitHooks\Module\Configuration\Domain\PrePush; |
|
7 | use PhpGitHooks\Module\Configuration\Domain\Undefined; |
|
8 | ||
9 | class PrePushFactory |
|
10 | { |
|
11 | /** |
|
12 | * @return PrePush |
|
13 | */ |
|
14 | public static function setUndefined() |
|
15 | { |
|
16 | return new PrePush( |
|
17 | new Undefined(true), |
|
18 | new Enabled(false), |
|
19 | PrePushExecuteFactory::setUndefined(), |
|
20 | MessagesFactory::setUndefined() |
|
21 | ); |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * @param array $data |
|
26 | * |
|
27 | * @return PrePush |
|
28 | */ |
|
29 | public static function fromArray(array $data) |
|
30 | { |
|
31 | return new PrePush( |
|
32 | new Undefined(false), |
|
33 | new Enabled($data['enabled']), |
|
34 | PrePushExecuteFactory::fromArray($data['process']), |
|
35 | isset($data['messages']) ? MessagesFactory::fromArray($data['messages']) : MessagesFactory::setUndefined() |
|
36 | ); |
|
37 | } |
|
38 | } |
|
39 |