Passed
Pull Request — master (#172)
by
unknown
07:58
created

ProductCodeBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A consumeEvent() 0 5 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 BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
16
use Elastica\Document;
17
use FOS\ElasticaBundle\Event\TransformEvent;
18
use Sylius\Component\Core\Model\ProductInterface;
19
use Sylius\Component\Core\Model\ProductTranslationInterface;
20
21
final class ProductCodeBuilder extends AbstractBuilder
22
{
23
    public const PROPERTY_NAME = 'code';
24
25
    public function consumeEvent(TransformEvent $event): void
26
    {
27
        $this->buildProperty($event, ProductInterface::class,
28
            function (ProductInterface $product, Document $document): void {
29
                $document->set(self::PROPERTY_NAME, $product->getCode());
30
            }
31
        );
32
    }
33
}
34