Completed
Pull Request — master (#146)
by Łukasz
10:35 queued 06:48
created

ProductReviewerProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A provide() 0 9 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sylius\ShopApiPlugin\Provider;
6
7
use Sylius\Component\Core\Model\ProductReviewerInterface;
8
use Webmozart\Assert\Assert;
9
10
final class ProductReviewerProvider implements ProductReviewerProviderInterface
11
{
12
    /**
13
     * @var CustomerProviderInterface
14
     */
15
    private $customerProvider;
16
17
    public function __construct(CustomerProviderInterface $customerProvider)
18
    {
19
        $this->customerProvider = $customerProvider;
20
    }
21
22
    public function provide(string $email): ProductReviewerInterface
23
    {
24
        /** @var ProductReviewerInterface $reviewer */
25
        $reviewer = $this->customerProvider->provide($email);
26
27
        Assert::isInstanceOf($reviewer, ProductReviewerInterface::class);
28
29
        return $reviewer;
30
    }
31
}
32