Passed
Push — master ( 1a7a28...c3773f )
by Mikołaj
03:50
created

AbstractBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildProperty() 0 11 2
A getSubscribedEvents() 0 4 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
14
15
use FOS\ElasticaBundle\Event\TransformEvent;
16
17
abstract class AbstractBuilder implements PropertyBuilderInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function buildProperty(TransformEvent $event, string $supportedModelClass, callable $callback): void
23
    {
24
        $model = $event->getObject();
25
26
        if (!$model instanceof $supportedModelClass) {
27
            return;
28
        }
29
30
        $document = $event->getDocument();
31
32
        $callback($model, $document);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public static function getSubscribedEvents(): array
39
    {
40
        return [
41
            TransformEvent::POST_TRANSFORM => 'consumeEvent',
42
        ];
43
    }
44
}
45