PopulateListener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A onPostIndexPopulate() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\ElasticaBundle\EventListener;
13
14
use FOS\ElasticaBundle\Event\PostIndexPopulateEvent;
15
use FOS\ElasticaBundle\Index\Resetter;
16
17
/**
18
 * PopulateListener.
19
 *
20
 * @author Oleg Andreyev <[email protected]>
21
 */
22
class PopulateListener
23
{
24
    /**
25
     * @var Resetter
26
     */
27
    private $resetter;
28
29
    /**
30
     * PopulateListener constructor.
31
     */
32 2
    public function __construct(Resetter $resetter)
33
    {
34 2
        $this->resetter = $resetter;
35 2
    }
36
37 2
    public function onPostIndexPopulate(PostIndexPopulateEvent $event): void
38
    {
39 2
        if (!$event->isReset()) {
40 1
            return;
41
        }
42
43 1
        $this->resetter->switchIndexAlias($event->getIndex(), $event->getOption('delete'));
44 1
    }
45
}
46