Skip to content

Commit

Permalink
Create SingleCommandApplicationDispatcher.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwriter committed Dec 4, 2023
1 parent 5c58e59 commit d164fd2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/SingleCommandApplicationDispatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Ghostwriter\Compliance;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Ghostwriter\EventDispatcher\Interface\DispatcherInterface;
use Ghostwriter\Compliance\Event\GitHubEvent;
use Symfony\Component\Console\Command\Command;

final readonly class SingleCommandApplicationDispatcher
{
public function __construct(
private DispatcherInterface $dispatcher,
) {
}

public function __invoke(
InputInterface $input,
OutputInterface $output
): int {
return $this->dispatcher
->dispatch(new GitHubEvent($input, $output))
->isPropagationStopped() ? Command::FAILURE : Command::SUCCESS;
}
}

0 comments on commit d164fd2

Please sign in to comment.