Completed
Push — master ( a8052f...413f40 )
by André
20:01 queued 05:56
created

RemoveTranslation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 35
loc 35
rs 10
c 1
b 0
f 0
wmc 4
lcom 1
cbo 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B receive() 27 27 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * This file is part of the eZ Publish Kernel package.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Search\Common\Slot;
10
11
use eZ\Publish\Core\SignalSlot\Signal;
12
use eZ\Publish\Core\Search\Common\Slot;
13
14
/**
15
 * A Search Engine slot handling RemoveTranslationSignal.
16
 */
17 View Code Duplication
class RemoveTranslation extends Slot
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    /**
20
     * Receive the given $signal and react on it.
21
     *
22
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
23
     */
24
    public function receive(Signal $signal)
25
    {
26
        if (!$signal instanceof Signal\ContentService\RemoveTranslationSignal) {
27
            return;
28
        }
29
30
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
31
            $signal->contentId
32
        );
33
        if (!$contentInfo->isPublished) {
34
            return;
35
        }
36
37
        $this->searchHandler->indexContent(
38
            $this->persistenceHandler->contentHandler()->load(
39
                $contentInfo->id,
40
                $contentInfo->currentVersionNo
41
            )
42
        );
43
44
        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
45
            $contentInfo->id
46
        );
47
        foreach ($locations as $location) {
48
            $this->searchHandler->indexLocation($location);
49
        }
50
    }
51
}
52