DoctrineEntityListener   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 53
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A postUpdate() 0 3 1
A preRemove() 0 3 1
A removeEntity() 0 3 1
A reindexEntity() 0 3 1
A postPersist() 0 3 1
1
<?php
2
3
namespace Mdiyakov\DoctrineSolrBundle\EventListener;
4
5
use Doctrine\ORM\Event\LifecycleEventArgs;
6
use Mdiyakov\DoctrineSolrBundle\Manager\IndexProcessManager;
7
8
class DoctrineEntityListener
9
{
10
    /**
11
     * @var IndexProcessManager
12
     */
13
    private $indexProcessManager;
14
15
    /**
16
     * @param IndexProcessManager $indexProcessManager
17
     */
18
    public function __construct(IndexProcessManager $indexProcessManager)
19
    {
20
        $this->indexProcessManager = $indexProcessManager;
21
    }
22
23
    /**
24
     * @param $entity
25
     * @param LifecycleEventArgs $event
26
     */
27
    public function postUpdate($entity, LifecycleEventArgs $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    public function postUpdate($entity, /** @scrutinizer ignore-unused */ LifecycleEventArgs $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        $this->reindexEntity($entity);
30
    }
31
32
    /**
33
     * @param $entity
34
     * @param LifecycleEventArgs $event
35
     */
36
    public function preRemove($entity, LifecycleEventArgs $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

36
    public function preRemove($entity, /** @scrutinizer ignore-unused */ LifecycleEventArgs $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38
        $this->removeEntity($entity);
39
    }
40
41
    /**
42
     * @param $entity
43
     * @param LifecycleEventArgs $event
44
     */
45
    public function postPersist($entity, LifecycleEventArgs $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

45
    public function postPersist($entity, /** @scrutinizer ignore-unused */ LifecycleEventArgs $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
    {
47
        $this->reindexEntity($entity);
48
    }
49
50
    /**
51
     * @param $entity
52
     */
53
    private function reindexEntity($entity)
54
    {
55
        $this->indexProcessManager->reindex($entity);
56
    }
57
58
    private function removeEntity($entity)
59
    {
60
        $this->indexProcessManager->remove($entity);
61
    }
62
}