| @@ 11-39 (lines=29) @@ | ||
| 8 | use PhpGitHooks\Module\Configuration\Domain\Messages; |
|
| 9 | use PhpGitHooks\Module\Configuration\Domain\PreCommit; |
|
| 10 | ||
| 11 | class PreCommitConfigurator |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @param IOInterface $io |
|
| 15 | * @param PreCommit $preCommit |
|
| 16 | * |
|
| 17 | * @return PreCommit |
|
| 18 | */ |
|
| 19 | public static function configure(IOInterface $io, PreCommit $preCommit) |
|
| 20 | { |
|
| 21 | $answer = $io->ask(HookQuestions::PRE_COMMIT_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER); |
|
| 22 | ||
| 23 | $preCommit = $preCommit->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer))); |
|
| 24 | ||
| 25 | if (true === $preCommit->isEnabled()) { |
|
| 26 | $rightMessageAnswer = $io |
|
| 27 | ->ask(HookQuestions::PRE_COMMIT_RIGHT_MESSAGE, HookQuestions::PRE_COMMIT_RIGHT_MESSAGE_DEFAULT); |
|
| 28 | $errorMessageAnswer = $io |
|
| 29 | ->ask(HookQuestions::PRE_COMMIT_ERROR_MESSAGE, HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT); |
|
| 30 | ||
| 31 | $preCommit = $preCommit->setMessages(new Messages( |
|
| 32 | new Message($rightMessageAnswer), |
|
| 33 | new Message($errorMessageAnswer) |
|
| 34 | )); |
|
| 35 | } |
|
| 36 | ||
| 37 | return $preCommit; |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 11-35 (lines=25) @@ | ||
| 8 | use PhpGitHooks\Module\Configuration\Domain\Messages; |
|
| 9 | use PhpGitHooks\Module\Configuration\Domain\PrePush; |
|
| 10 | ||
| 11 | class PrePushConfigurator |
|
| 12 | { |
|
| 13 | public static function configure(IOInterface $input, PrePush $prePush) |
|
| 14 | { |
|
| 15 | $answer = $input->ask(HookQuestions::PRE_PUSH_HOOK_QUESTION, HookQuestions::DEFAULT_TOOL_ANSWER); |
|
| 16 | ||
| 17 | $prePush = $prePush->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer))); |
|
| 18 | ||
| 19 | if (true === $prePush->isEnabled()) { |
|
| 20 | $rightMessageAnswer = $input |
|
| 21 | ->ask(HookQuestions::PRE_PUSH_RIGHT_MESSAGE, HookQuestions::PRE_PUSH_RIGHT_MESSAGE_DEFAULT); |
|
| 22 | $errorMessageAnswer = $input |
|
| 23 | ->ask(HookQuestions::PRE_PUSH_ERROR_MESSAGE, HookQuestions::PRE_PUSH_ERROR_MESSAGE_DEFAULT); |
|
| 24 | ||
| 25 | $prePush = $prePush->setMessages( |
|
| 26 | new Messages( |
|
| 27 | new Message($rightMessageAnswer), |
|
| 28 | new Message($errorMessageAnswer) |
|
| 29 | ) |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | ||
| 33 | return $prePush; |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||