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

PriceViewFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 2
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