Passed
Pull Request — master (#184)
by
unknown
04:04
created

QueryDispatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A dispatchNewQuery() 0 6 1
1
<?php
2
/*
3
4
This file was created by developers working at BitBag
5
6
Do you need more information about us and what we do? Visit our   website!
7
8
We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
9
*/
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusElasticsearchPlugin\Notifier;
13
14
use BitBag\SyliusElasticsearchPlugin\EventListener\QueryCreatedEventInterface;
15
use BitBag\SyliusElasticsearchPlugin\Factory\QueryCreatedEventFactoryInterface;
16
use Elastica\Query\AbstractQuery;
17
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
18
19
final class QueryDispatcher implements QueryDispatcherInterface
20
{
21
    /** @var QueryCreatedEventFactoryInterface */
22
    private $factory;
23
24
    /** @var EventDispatcherInterface */
25
    private $eventDispatcher;
26
27
    public function __construct(
28
        QueryCreatedEventFactoryInterface $factory,
29
        EventDispatcherInterface $eventDispatcher
30
    ) {
31
        $this->factory = $factory;
32
        $this->eventDispatcher = $eventDispatcher;
33
    }
34
35
    public function dispatchNewQuery(AbstractQuery $boolQuery): QueryCreatedEventInterface
36
    {
37
        $event = $this->factory->createNewEvent($boolQuery);
38
        $this->eventDispatcher->dispatch($event, QueryCreatedEventInterface::NAME);
0 ignored issues
show
Bug introduced by
The constant BitBag\SyliusElasticsear...tedEventInterface::NAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
39
40
        return $event;
41
    }
42
}
43