DataCollectorListener::onQueryExecuted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\MongoDbBundle\Event\Listener;
6
7
use Facile\MongoDbBundle\Event\ConnectionEvent;
8
use Facile\MongoDbBundle\Event\QueryEvent;
9
use Facile\MongoDbBundle\Services\Loggers\DataCollectorLoggerInterface;
10
11
/**
12
 * Class DataCollectorListener.
13
 *
14
 * @internal
15
 */
16
final class DataCollectorListener
17
{
18
    /** @var DataCollectorLoggerInterface */
19
    private $logger;
20
21
    /**
22
     * DataCollectorListener constructor.
23 8
     *
24
     * @param DataCollectorLoggerInterface $logger
25 8
     */
26 8
    public function __construct(DataCollectorLoggerInterface $logger)
27
    {
28
        $this->logger = $logger;
29
    }
30
31 5
    /**
32
     * @param ConnectionEvent $event
33 5
     */
34 5
    public function onConnectionClientCreated(ConnectionEvent $event)
35
    {
36
        $this->logger->addConnection($event->getClientName());
37
    }
38
39 1
    /**
40
     * @param QueryEvent $event
41 1
     */
42 1
    public function onQueryExecuted(QueryEvent $event)
43
    {
44
        $this->logger->logQuery($event->getQueryLog());
45
    }
46
}
47