Completed
Push — ezp-30646 ( a44352...64df2d )
by
unknown
15:12
created

SectionEventSubscriber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 41.18 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 7
dl 7
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 6 1
A onAssignSection() 7 7 1

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
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Search\Common\EventSubscriber;
8
9
use eZ\Publish\API\Repository\Events\Section\AssignSectionEvent;
10
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11
12
class SectionEventSubscriber extends AbstractSearchEventSubscriber implements EventSubscriberInterface
13
{
14
    public static function getSubscribedEvents(): array
15
    {
16
        return [
17
            AssignSectionEvent::class => 'onAssignSection',
18
        ];
19
    }
20
21 View Code Duplication
    public function onAssignSection(AssignSectionEvent $event)
22
    {
23
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($event->getContentInfo()->id);
24
        $this->searchHandler->indexContent(
25
            $this->persistenceHandler->contentHandler()->load($contentInfo->id, $contentInfo->currentVersionNo)
26
        );
27
    }
28
}
29