Code Duplication    Length = 31-33 lines in 2 locations

src/PhpGitHooks/Infrastructure/CommandBus/CommandBus/CommandBus.php 1 location

@@ 8-38 (lines=31) @@
5
use PhpGitHooks\Infrastructure\CommandBus\BusOptionsResolver;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
8
class CommandBus
9
{
10
    /**
11
     * @var ContainerInterface
12
     */
13
    private $container;
14
    /**
15
     * @var BusOptionsResolver
16
     */
17
    private $optionsResolver;
18
19
    /**
20
     * CommandBus constructor.
21
     *
22
     * @param ContainerInterface $container
23
     * @param BusOptionsResolver $optionsResolver
24
     */
25
    public function __construct(ContainerInterface $container, BusOptionsResolver $optionsResolver)
26
    {
27
        $this->container = $container;
28
        $this->optionsResolver = $optionsResolver;
29
    }
30
31
    /**
32
     * @param CommandInterface $command
33
     */
34
    public function handle(CommandInterface $command)
35
    {
36
        $this->container->get($this->optionsResolver->getOption('\\'.get_class($command)))->handle($command);
37
    }
38
}
39

src/PhpGitHooks/Infrastructure/CommandBus/QueryBus/QueryBus.php 1 location

@@ 8-40 (lines=33) @@
5
use PhpGitHooks\Infrastructure\CommandBus\BusOptionsResolver;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
8
class QueryBus
9
{
10
    /**
11
     * @var ContainerInterface
12
     */
13
    private $container;
14
    /**
15
     * @var BusOptionsResolver
16
     */
17
    private $optionsResolver;
18
19
    /**
20
     * QueryBus constructor.
21
     *
22
     * @param ContainerInterface $container
23
     * @param BusOptionsResolver $optionsResolver
24
     */
25
    public function __construct(ContainerInterface $container, BusOptionsResolver $optionsResolver)
26
    {
27
        $this->container = $container;
28
        $this->optionsResolver = $optionsResolver;
29
    }
30
31
    /**
32
     * @param QueryInterface $query
33
     *
34
     * @return mixed
35
     */
36
    public function handle(QueryInterface $query)
37
    {
38
        return $this->container->get($this->optionsResolver->getOption('\\'.get_class($query)))->handle($query);
39
    }
40
}
41