コード例 #1
0
ファイル: JsonLintTool.php プロジェクト: bruli/php-git-hooks
 /**
  * @param array  $files
  * @param string $errorMessage
  */
 public function execute(array $files, $errorMessage)
 {
     $jsonFilesResponse = $this->queryBus->handle(new JsonFilesExtractorQuery($files));
     if (true === $this->jsonFilesExists($jsonFilesResponse->getFiles())) {
         $this->jsonLintToolExecutor->execute($jsonFilesResponse->getFiles(), $errorMessage);
     }
 }
コード例 #2
0
 public function configure()
 {
     /** @var GitIgnoreDataResponse $gitIgnoreContent */
     $gitIgnoreContent = $this->queryBus->handle(new GitIgnoreExtractorQuery());
     if (false === $this->isFileIgnored($gitIgnoreContent->getContent())) {
         $content = $this->getContent($gitIgnoreContent->getContent());
         $this->commandBus->handle(new GitIgnoreWriterCommand($content));
     }
 }
コード例 #3
0
ファイル: CommitMsgTool.php プロジェクト: bruli/php-git-hooks
 /**
  * @param InputInterface $input
  *
  * @throws InvalidCommitMessageException
  */
 public function run(InputInterface $input)
 {
     /** @var ConfigurationDataResponse $configurationDataResponse */
     $configurationDataResponse = $this->queryBus->handle(new ConfigurationDataFinderQuery());
     if (true === $configurationDataResponse->getCommitMsg()->isCommitMsg()) {
         $commitContent = $this->commitMessageFinder->find($input->getFirstArgument());
         $validMessage = $this->isValidCommitMessage($configurationDataResponse->getCommitMsg()->getRegularExpression(), $commitContent);
         if (false === $validMessage) {
             throw new InvalidCommitMessageException();
         }
     }
 }
コード例 #4
0
ファイル: PreCommitTool.php プロジェクト: bruli/php-git-hooks
 /**
  * @param array $committedFiles
  *
  * @return array
  */
 private function getPhpFiles(array $committedFiles)
 {
     /**
      * @var PhpFilesResponse
      */
     $phpFilesResponse = $this->queryBus->handle(new PhpFilesExtractorQuery($committedFiles));
     return $phpFilesResponse->getFiles();
 }
コード例 #5
0
ファイル: PrePushTool.php プロジェクト: bruli/php-git-hooks
 /**
  * @param string $remote
  * @param string $url
  *
  * @throws InvalidPushException
  */
 public function execute($remote, $url)
 {
     /** @var ConfigurationDataResponse $configurationData */
     $configurationData = $this->queryBus->handle(new ConfigurationDataFinderQuery());
     $prePushResponse = $configurationData->getPrePush();
     if (true === $prePushResponse->isPrePush()) {
         $this->output->writeln(self::PRE_PUSH_HOOK);
         $this->executeOriginalHook($remote, $url, $prePushResponse->getErrorMessage());
         $phpunitResponse = $prePushResponse->getPhpUnit();
         if (true === $phpunitResponse->isPhpunit()) {
             $this->commandBus->handle(new PhpUnitToolCommand($phpunitResponse->isPhpunitRandomMode(), $phpunitResponse->getPhpunitOptions(), $prePushResponse->getErrorMessage()));
             $phpunitStrictCoverageResponse = $prePushResponse->getPhpUnitStrictCoverage();
             if (true === $phpunitStrictCoverageResponse->isPhpunitStrictCoverage()) {
                 $this->commandBus->handle(new StrictCoverageCommand($phpunitStrictCoverageResponse->getMinimum(), $prePushResponse->getErrorMessage()));
             }
             $phpunitGuardCoverageResponse = $prePushResponse->getPhpUnitGuardCoverage();
             if (true === $phpunitGuardCoverageResponse->isEnabled()) {
                 $this->commandBus->handle(new GuardCoverageCommand($phpunitGuardCoverageResponse->getWarningMessage()));
             }
         }
         $this->output->writeln(GoodJobLogoResponse::paint($prePushResponse->getRightMessage()));
     }
 }
コード例 #6
0
ファイル: ComposerTool.php プロジェクト: bruli/php-git-hooks
 /**
  * @param array $files
  *
  * @return ComposerFilesResponse
  */
 private function getComposerFilesResponse(array $files)
 {
     return $this->queryBus->handle(new ComposerFilesExtractorQuery($files));
 }