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

ProductVariantInWishlistGuard   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 4 2
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