/** * @param PreCommit $preCommit * @param Composer $composer * @param JsonLint $jsonLint * @param PhpLint $phpLint * @param PhpMd $phpMd * @param PhpCs $phpCs * @param PhpCsFixer $phpCsFixer * @param PhpUnit $phpUnit * @param PhpUnitStrictCoverage $phpUnitStrictCoverage * @param PhpUnitGuardCoverage $phpUnitGuardCoverage * @param CommitMsg $commitMsg * @param PrePush $prePush * @param PhpUnit $prePushPhpUnit * @param PhpUnitStrictCoverage $prePushStrictCoverage * @param PhpUnitGuardCoverage $prePushGuardCoverage * * @return ConfigurationDataResponse */ public static function build(PreCommit $preCommit, Composer $composer, JsonLint $jsonLint, PhpLint $phpLint, PhpMd $phpMd, PhpCs $phpCs, PhpCsFixer $phpCsFixer, PhpUnit $phpUnit, PhpUnitStrictCoverage $phpUnitStrictCoverage, PhpUnitGuardCoverage $phpUnitGuardCoverage, CommitMsg $commitMsg, PrePush $prePush, PhpUnit $prePushPhpUnit, PhpUnitStrictCoverage $prePushStrictCoverage, PhpUnitGuardCoverage $prePushGuardCoverage) { $commitMsgResponse = new CommitMsgResponse($commitMsg->isEnabled(), $commitMsg->getRegularExpression()->value()); $prePushResponse = new PrePushResponse($prePush->isEnabled(), $prePush->getMessages()->getRightMessage(), $prePush->getMessages()->getErrorMessage(), new PhpUnitResponse($prePushPhpUnit->isEnabled(), $prePushPhpUnit->getRandomMode()->value(), $prePushPhpUnit->getOptions()->value()), new PhpUnitStrictCoverageResponse($prePushStrictCoverage->isEnabled(), $prePushStrictCoverage->getMinimumStrictCoverage()->value()), new PhpUnitGuardCoverageResponse($prePushGuardCoverage->isEnabled(), $prePushGuardCoverage->getWarningMessage()->value())); $preCommitResponse = new PreCommitResponse($preCommit->isEnabled(), $preCommit->getMessages()->getRightMessage()->value(), $preCommit->getMessages()->getErrorMessage()->value(), $composer->isEnabled(), $jsonLint->isEnabled(), $phpLint->isEnabled(), new PhpMdResponse($phpMd->isEnabled(), $phpMd->getOptions()->value()), new PhpCsResponse($phpCs->isEnabled(), $phpCs->getStandard()->value()), new PhpCsFixerResponse($phpCsFixer->isEnabled(), $phpCsFixer->getLevels()->getPsr0()->value(), $phpCsFixer->getLevels()->getPsr1()->value(), $phpCsFixer->getLevels()->getPsr2()->value(), $phpCsFixer->getLevels()->getSymfony()->value()), new PhpUnitResponse($phpUnit->isEnabled(), $phpUnit->getRandomMode()->value(), $phpUnit->getOptions()->value()), new PhpUnitStrictCoverageResponse($phpUnitStrictCoverage->isEnabled(), $phpUnitStrictCoverage->getMinimumStrictCoverage()->value()), new PhpUnitGuardCoverageResponse($phpUnitGuardCoverage->isEnabled(), $phpUnitGuardCoverage->getWarningMessage()->value())); return new ConfigurationDataResponse($preCommitResponse, $commitMsgResponse, $prePushResponse); }
/** * @param IOInterface $io * @param PhpUnit $phpUnit * * @return PhpUnit */ public static function configure(IOInterface $io, PhpUnit $phpUnit) { /** @var PhpUnit $phpUnit */ if (true === $phpUnit->isUndefined()) { $answer = $io->ask(HookQuestions::PHPUNIT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER); $phpUnit = $phpUnit->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer))); if (true === $phpUnit->isEnabled()) { $randomAnswer = $io->ask(HookQuestions::PHPUNIT_RANDOM_MODE, HookQuestions::DEFAULT_TOOL_ANSWER); $optionsAnswer = $io->ask(HookQuestions::PHPUNIT_OPTIONS, null); $randomMode = new PhpUnitRandomMode(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($randomAnswer)); $options = new PhpUnitOptions($optionsAnswer); $phpUnit = $phpUnit->setRandomModeAndOptions($randomMode, $options); } } return $phpUnit; }