Completed
Pull Request — master (#290)
by
unknown
36:49 queued 34:03
created

PriceViewFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\SyliusShopApiPlugin\Factory;
6
7
use Sylius\SyliusShopApiPlugin\View\PriceView;
8
9
final class PriceViewFactory implements PriceViewFactoryInterface
10
{
11
    /** @var string */
12
    private $priceViewClass;
13
14
    public function __construct(string $priceViewClass)
15
    {
16
        $this->priceViewClass = $priceViewClass;
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function create(int $price, string $currency): PriceView
23
    {
24
        /** @var PriceView $priceView */
25
        $priceView = new $this->priceViewClass();
26
        $priceView->current = $price;
27
        $priceView->currency = $currency;
28
29
        return $priceView;
30
    }
31
}
32