ProductVariantPricesTransformer::transform()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
cc 1
nc 1
nop 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.io and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusVueStorefrontPlugin\Sylius\Transformer\SyliusProduct;
14
15
use BitBag\SyliusVueStorefrontPlugin\Document\Product\Price;
16
use BitBag\SyliusVueStorefrontPlugin\Sylius\Provider\ChannelProviderInterface;
17
use Sylius\Component\Core\Model\ProductVariantInterface;
18
19
final class ProductVariantPricesTransformer implements ProductVariantPricesTransformerInterface
20
{
21
    /** @var ChannelProviderInterface */
22
    private $channelProvider;
23
24
    public function __construct(ChannelProviderInterface $channelProvider)
25
    {
26
        $this->channelProvider = $channelProvider;
27
    }
28
29
    public function transform(ProductVariantInterface $productVariant): Price
30
    {
31
        $channelPricing = $productVariant->getChannelPricingForChannel($this->channelProvider->provide());
32
        $price = (float) $channelPricing->getPrice();
33
        //        $originalPrice = (float) $channelPricing->getOriginalPrice();
34
35
        return new Price(
36
            $price,
37
            $price,
38
            $price,
39
            $price,
40
            $price,
41
            $price,
42
            $price,
43
            $price,
44
            $price,
45
            null,
46
            null,
47
            null,
48
            $price,
49
            $price,
50
            $price
51
        );
52
    }
53
}
54