ShopUserWishlistResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 3 1
A __construct() 0 6 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusWishlistPlugin\Resolver;
12
13
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface;
14
use BitBag\SyliusWishlistPlugin\Factory\WishlistFactoryInterface;
15
use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface;
16
use Sylius\Component\Core\Model\ShopUserInterface;
17
18
final class ShopUserWishlistResolver implements ShopUserWishlistResolverInterface
19
{
20
    private WishlistRepositoryInterface $wishlistRepository;
21
22
    private WishlistFactoryInterface $wishlistFactory;
23
24
    public function __construct(
25
        WishlistRepositoryInterface $wishlistRepository,
26
        WishlistFactoryInterface $wishlistFactory
27
    ) {
28
        $this->wishlistRepository = $wishlistRepository;
29
        $this->wishlistFactory = $wishlistFactory;
30
    }
31
32
    public function resolve(ShopUserInterface $user): WishlistInterface
33
    {
34
        return $this->wishlistRepository->findOneByShopUser($user) ?? $this->wishlistFactory->createForUser($user);
35
    }
36
}
37