Passed
Pull Request — master (#81)
by
unknown
04:59
created

createWithProductVariant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
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
 * You can find more information about us on https://bitbag.io and write us
7
 * an email on [email protected].
8
 */
9
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusWishlistPlugin\Facade;
13
14
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface;
15
use BitBag\SyliusWishlistPlugin\Factory\WishlistProductFactoryInterface;
16
use Sylius\Component\Core\Model\ProductInterface;
17
use Sylius\Component\Core\Model\ProductVariantInterface;
18
19
final class WishlistProductFactoryFacade implements WishlistProductFactoryFacadeInterface
20
{
21
    private WishlistProductFactoryInterface $wishlistProductFactory;
22
23
    public function __construct(WishlistProductFactoryInterface $wishlistProductFactory)
24
    {
25
        $this->wishlistProductFactory = $wishlistProductFactory;
26
    }
27
28
    public function createWithProduct(WishlistInterface $wishlist, ProductInterface $product): void
29
    {
30
        $wishlistProduct = $this->wishlistProductFactory->createForWishlistAndProduct($wishlist, $product);
31
32
        $wishlist->addWishlistProduct($wishlistProduct);
33
    }
34
35
    public function createWithProductVariant(WishlistInterface $wishlist, ProductVariantInterface $productVariant): void
36
    {
37
        $wishlistProductWithVariant = $this->wishlistProductFactory->createForWishlistAndVariant($wishlist, $productVariant);
38
39
        $wishlist->addWishlistProduct($wishlistProductWithVariant);
40
    }
41
}
42