Passed
Pull Request — master (#81)
by
unknown
05:16 queued 32s
created

ProductVariantInWishlistGuard::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 4
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\Guard;
13
14
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface;
15
use BitBag\SyliusWishlistPlugin\Exception\ProductVariantAlreadyInWishlistException;
16
use Sylius\Component\Core\Model\ProductVariantInterface;
17
18
final class ProductVariantInWishlistGuard implements ProductVariantInWishlistGuardInterface
19
{
20
    public function check(WishlistInterface $wishlist, ProductVariantInterface $productVariant): void
21
    {
22
        if ($wishlist->hasProductVariant($productVariant)) {
23
            throw new ProductVariantAlreadyInWishlistException();
24
        }
25
    }
26
}
27