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

ProductCodeBuilder::consumeEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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