@@ 10-35 (lines=26) @@ | ||
7 | use PhpGitHooks\Module\Configuration\Domain\Enabled; |
|
8 | use PhpGitHooks\Module\Configuration\Domain\RegularExpression; |
|
9 | ||
10 | class CommitMsgConfigurator |
|
11 | { |
|
12 | /** |
|
13 | * @param IOInterface $io |
|
14 | * @param CommitMsg $commitMsg |
|
15 | * |
|
16 | * @return CommitMsg |
|
17 | */ |
|
18 | public static function configure(IOInterface $io, CommitMsg $commitMsg) |
|
19 | { |
|
20 | $answer = $io->ask(HookQuestions::COMMIT_MSG_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER); |
|
21 | ||
22 | $commitMsg = $commitMsg->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer))); |
|
23 | ||
24 | if (true === $commitMsg->isEnabled()) { |
|
25 | $regularExpressionAnswer = $io->ask( |
|
26 | HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION, |
|
27 | HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION_ANSWER |
|
28 | ); |
|
29 | ||
30 | $commitMsg = $commitMsg->addRegularExpression(new RegularExpression($regularExpressionAnswer)); |
|
31 | } |
|
32 | ||
33 | return $commitMsg; |
|
34 | } |
|
35 | } |
|
36 |
@@ 10-31 (lines=22) @@ | ||
7 | use PhpGitHooks\Module\Configuration\Domain\PhpMd; |
|
8 | use PhpGitHooks\Module\Configuration\Domain\PhpMdOptions; |
|
9 | ||
10 | class PhpMdConfigurator |
|
11 | { |
|
12 | /** |
|
13 | * @param IOInterface $io |
|
14 | * @param PhpMd $phpMd |
|
15 | * |
|
16 | * @return PhpMd |
|
17 | */ |
|
18 | public static function configure(IOInterface $io, PhpMd $phpMd) |
|
19 | { |
|
20 | if (true === $phpMd->isUndefined()) { |
|
21 | $answer = $io->ask(HookQuestions::PHPMD_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER); |
|
22 | $phpMd = $phpMd->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer))); |
|
23 | ||
24 | $optionsAnswer = $io->ask(HookQuestions::PHPMD_OPTIONS, null); |
|
25 | $options = new PhpMdOptions($optionsAnswer); |
|
26 | $phpMd = $phpMd->setOptions($options); |
|
27 | } |
|
28 | ||
29 | return $phpMd; |
|
30 | } |
|
31 | } |
|
32 |
@@ 10-39 (lines=30) @@ | ||
7 | use PhpGitHooks\Module\Configuration\Domain\MinimumStrictCoverage; |
|
8 | use PhpGitHooks\Module\Configuration\Domain\PhpUnitStrictCoverage; |
|
9 | ||
10 | class PhpUnitStrictCoverageConfigurator |
|
11 | { |
|
12 | /** |
|
13 | * @param IOInterface $io |
|
14 | * @param PhpUnitStrictCoverage $strictCoverage |
|
15 | * |
|
16 | * @return PhpUnitStrictCoverage |
|
17 | */ |
|
18 | public static function configure(IOInterface $io, PhpUnitStrictCoverage $strictCoverage) |
|
19 | { |
|
20 | if (true === $strictCoverage->isUndefined()) { |
|
21 | $strictCoverageAnswer = $io->ask( |
|
22 | HookQuestions::PHPUNIT_STRICT_COVERAGE, |
|
23 | HookQuestions::DEFAULT_TOOL_ANSWER |
|
24 | ); |
|
25 | ||
26 | $strictCoverage = $strictCoverage->setEnabled( |
|
27 | new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($strictCoverageAnswer)) |
|
28 | ); |
|
29 | ||
30 | /** @var PhpUnitStrictCoverage $strictCoverage */ |
|
31 | if (true === $strictCoverage->isEnabled()) { |
|
32 | $minimum = $io->ask(HookQuestions::PHPUNIT_STRICT_COVERAGE_MINIMUM, 0.00); |
|
33 | $strictCoverage = $strictCoverage->setStrictCoverage(new MinimumStrictCoverage((float) $minimum)); |
|
34 | } |
|
35 | } |
|
36 | ||
37 | return $strictCoverage; |
|
38 | } |
|
39 | } |
|
40 |