Passed
Push — master ( 190ec1...02ba08 )
by
unknown
12:54 queued 05:50
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 Elastica\Document;
16
use FOS\ElasticaBundle\Event\TransformEvent;
17
use Sylius\Component\Core\Model\ProductInterface;
18
19
final class ProductCodeBuilder extends AbstractBuilder
20
{
21
    public const PROPERTY_NAME = 'code';
22
23
    public function consumeEvent(TransformEvent $event): void
24
    {
25
        $this->buildProperty($event, ProductInterface::class,
26
            function (ProductInterface $product, Document $document): void {
27
                $document->set(self::PROPERTY_NAME, $product->getCode());
28
            }
29
        );
30
    }
31
}
32