/** * @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 PreCommit $preCommit * @param CommitMsg $commitMsg * @param PrePush $prePush * * @return array */ public static function transform(PreCommit $preCommit, CommitMsg $commitMsg, PrePush $prePush) { $tools = $preCommit->getExecute()->execute(); $prePushTools = $prePush->getExecute()->execute(); $composer = $tools[0]; $jsonLint = $tools[1]; $phpLint = $tools[2]; /** @var PhpMd $phpMd */ $phpMd = $tools[3]; /** @var PhpCs $phpCs */ $phpCs = $tools[4]; /** @var PhpCsFixer $phpCsFixer */ $phpCsFixer = $tools[5]; /** @var PhpUnit $phpunit */ $phpunit = $tools[6]; /** @var PhpUnitStrictCoverage $phpUnitStrictCoverage */ $phpUnitStrictCoverage = $tools[7]; /** @var PhpUnitGuardCoverage $phpUnitGuardCoverage */ $phpUnitGuardCoverage = $tools[8]; /** @var PhpUnit $phpunitPrePush */ $phpunitPrePush = $prePushTools[0]; /** @var PhpUnitStrictCoverage $phpUnitStrictCoveragePrePush */ $phpUnitStrictCoveragePrePush = $prePushTools[1]; /** @var PhpUnitGuardCoverage $phpUnitGuardCoveragePrePush */ $phpUnitGuardCoveragePrePush = $prePushTools[2]; return ['pre-commit' => ['enabled' => $preCommit->isEnabled(), 'execute' => ['composer' => $composer->isEnabled(), 'jsonlint' => $jsonLint->isEnabled(), 'phplint' => $phpLint->isEnabled(), 'phpmd' => ['enabled' => $phpMd->isEnabled(), 'options' => $phpMd->getOptions()->value()], 'phpcs' => ['enabled' => $phpCs->isEnabled(), 'standard' => $phpCs->getStandard()->value()], 'php-cs-fixer' => ['enabled' => $phpCsFixer->isEnabled(), 'levels' => ['psr0' => $phpCsFixer->getLevels()->getPsr0()->value(), 'psr1' => $phpCsFixer->getLevels()->getPsr1()->value(), 'psr2' => $phpCsFixer->getLevels()->getPsr2()->value(), 'symfony' => $phpCsFixer->getLevels()->getSymfony()->value()], 'options' => $phpCsFixer->getOptions()->value()], 'phpunit' => ['enabled' => $phpunit->isEnabled(), 'random-mode' => $phpunit->getRandomMode()->value(), 'options' => $phpunit->getOptions()->value(), 'strict-coverage' => ['enabled' => $phpUnitStrictCoverage->isEnabled(), 'minimum' => $phpUnitStrictCoverage->getMinimumStrictCoverage()->value()], 'guard-coverage' => ['enabled' => $phpUnitGuardCoverage->isEnabled(), 'message' => $phpUnitGuardCoverage->getWarningMessage()->value()]]], 'message' => ['right-message' => $preCommit->getMessages()->getRightMessage()->value(), 'error-message' => $preCommit->getMessages()->getErrorMessage()->value()]], 'commit-msg' => ['enabled' => $commitMsg->isEnabled(), 'regular-expression' => $commitMsg->getRegularExpression()->value()], 'pre-push' => ['enabled' => $prePush->isEnabled(), 'execute' => ['phpunit' => ['enabled' => $phpunitPrePush->isEnabled(), 'random-mode' => $phpunitPrePush->getRandomMode()->value(), 'options' => $phpunitPrePush->getOptions()->value(), 'strict-coverage' => ['enabled' => $phpUnitStrictCoveragePrePush->isEnabled(), 'minimum' => $phpUnitStrictCoveragePrePush->getMinimumStrictCoverage()->value()], 'guard-coverage' => ['enabled' => $phpUnitGuardCoveragePrePush->isEnabled(), 'message' => $phpUnitGuardCoveragePrePush->getWarningMessage()->value()]]], 'message' => ['right-message' => $prePush->getMessages()->getRightMessage()->value(), 'error-message' => $prePush->getMessages()->getErrorMessage()->value()]]]; }
/** * @param CommitMsg $commitMsgData * @param IOInterface $io * * @return CommitMsg */ public function process(CommitMsg $commitMsgData, IOInterface $io) { $this->io = $io; if (true === $commitMsgData->isUndefined()) { $commitMsgData = CommitMsgConfigurator::configure($this->io, $commitMsgData); } return $commitMsgData; }