Passed
Push — master ( 440273...190ec1 )
by
unknown
13:12 queued 05:43
created

ProductTaxonIndexListener::updateIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file has been created by developers from BitBag.
7
 * Feel free to contact us once you face any issues or want to start
8
 * another great project.
9
 * You can find more information about us on https://bitbag.shop and write us
10
 * an email on [email protected].
11
 */
12
13
namespace BitBag\SyliusElasticsearchPlugin\EventListener;
14
15
use BitBag\SyliusElasticsearchPlugin\Refresher\ResourceRefresherInterface;
16
use Sylius\Component\Core\Model\ProductTaxonInterface;
17
use Sylius\Component\Resource\Model\ResourceInterface;
18
use Symfony\Component\EventDispatcher\GenericEvent;
19
use Webmozart\Assert\Assert;
20
21
final class ProductTaxonIndexListener
22
{
23
    /** @var ResourceRefresherInterface */
24
    private $resourceRefresher;
25
26
    /** @var string */
27
    private $objectPersisterId;
28
29
    public function __construct(ResourceRefresherInterface $resourceRefresher, string $objectPersisterId)
30
    {
31
        $this->resourceRefresher = $resourceRefresher;
32
        $this->objectPersisterId = $objectPersisterId;
33
    }
34
35
    public function updateIndex(ProductTaxonInterface $productTaxon): void
36
    {
37
        $this->resourceRefresher->refresh($productTaxon->getProduct(), $this->objectPersisterId);
0 ignored issues
show
Bug introduced by
It seems like $productTaxon->getProduct() can also be of type null; however, parameter $resource of BitBag\SyliusElasticsear...herInterface::refresh() does only seem to accept Sylius\Component\Resource\Model\ResourceInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        $this->resourceRefresher->refresh(/** @scrutinizer ignore-type */ $productTaxon->getProduct(), $this->objectPersisterId);
Loading history...
38
    }
39
}
40