Completed
Push — ezp-30646 ( 6400c7...ee4911 )
by
unknown
21:35
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
dl 7
loc 17
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 7

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
namespace eZ\Publish\Core\Search\Common\EventSubscriber;
4
5
use eZ\Publish\Core\Event\Section\AssignSectionEvent;
6
use eZ\Publish\Core\Event\Section\SectionEvents;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
class SectionEventSubscriber extends AbstractSearchEventSubscriber implements EventSubscriberInterface
10
{
11
    public static function getSubscribedEvents(): array
12
    {
13
        return [
14
            SectionEvents::ASSIGN_SECTION => 'onAssignSection',
15
        ];
16
    }
17
18 View Code Duplication
    public function onAssignSection(AssignSectionEvent $event)
19
    {
20
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($event->getContentInfo()->id);
21
        $this->searchHandler->indexContent(
22
            $this->persistenceHandler->contentHandler()->load($contentInfo->id, $contentInfo->currentVersionNo)
23
        );
24
    }
25
}