PhpGitHooks\Module\PhpCsFixer\Contract\CommandHandler\PhpCsFixerToolCommandHandler::handle PHP Метод

handle() публичный Метод

public handle ( Bruli\EventBusBundle\CommandBus\CommandInterface $command )
$command Bruli\EventBusBundle\CommandBus\CommandInterface
    public function handle(CommandInterface $command)
    {
        $this->phpCsFixerTool->execute($command->getFiles(), $command->isPsr0(), $command->isPsr1(), $command->isPsr2(), $command->isSymfony(), $command->getOptions(), $command->getErrorMessage());
    }

Usage Example

 /**
  * @test
  */
 public function itShouldWorksFine()
 {
     $phpCsFixerOptions = PhpCsFixerOptionsStub::random();
     $configurationData = ConfigurationDataResponseStub::createAllEnabled();
     $phpFiles = FilesCommittedStub::createOnlyPhpFiles();
     $outputMessagePsr0 = new PreCommitOutputWriter('Checking psr0 code style with PHP-CS-FIXER');
     $this->shouldWriteOutput($outputMessagePsr0->getMessage());
     foreach ($phpFiles as $file) {
         $this->shouldProcessPhpCsFixerTool($file, 'psr0', $phpCsFixerOptions->value(), null);
     }
     $this->shouldWriteLnOutput($outputMessagePsr0->getSuccessfulMessage());
     $outputMessagePsr1 = new PreCommitOutputWriter('Checking psr1 code style with PHP-CS-FIXER');
     $this->shouldWriteOutput($outputMessagePsr1->getMessage());
     foreach ($phpFiles as $file) {
         $this->shouldProcessPhpCsFixerTool($file, 'psr1', $phpCsFixerOptions->value(), null);
     }
     $this->shouldWriteLnOutput($outputMessagePsr1->getSuccessfulMessage());
     $outputMessagePsr2 = new PreCommitOutputWriter('Checking psr2 code style with PHP-CS-FIXER');
     $this->shouldWriteOutput($outputMessagePsr2->getMessage());
     foreach ($phpFiles as $file) {
         $this->shouldProcessPhpCsFixerTool($file, 'psr2', $phpCsFixerOptions->value(), null);
     }
     $this->shouldWriteLnOutput($outputMessagePsr2->getSuccessfulMessage());
     $outputMessageSymfony = new PreCommitOutputWriter('Checking symfony code style with PHP-CS-FIXER');
     $this->shouldWriteOutput($outputMessageSymfony->getMessage());
     foreach ($phpFiles as $file) {
         $this->shouldProcessPhpCsFixerTool($file, 'symfony', $phpCsFixerOptions->value(), null);
     }
     $this->shouldWriteLnOutput($outputMessageSymfony->getSuccessfulMessage());
     $this->phpCsFixerToolCommandHandler->handle(new PhpCsFixerToolCommand($phpFiles, $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr0(), $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr1(), $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr2(), $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerSymfony(), $phpCsFixerOptions->value(), $configurationData->getPreCommit()->getErrorMessage()));
 }
PhpCsFixerToolCommandHandler