Completed
Push — master ( 0b395f...10fe71 )
by Andrii
03:11
created

PriceFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * API for Billing
4
 *
5
 * @link      https://github.com/hiqdev/billing-hiapi
6
 * @package   billing-hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\billing\hiapi\price;
12
13
use hiqdev\php\billing\price\EnumPrice;
14
use hiqdev\php\billing\price\SinglePrice;
15
16
/**
17
 * Class PriceFactory.
18
 *
19
 * @author Dmytro Naumenko <[email protected]>
20
 */
21
class PriceFactory extends \hiqdev\php\billing\price\PriceFactory
22
{
23
    protected $creators = [
24
        SinglePrice::class => 'createSinglePrice',
25
        EnumPrice::class => 'createEnumPrice',
26
        TemplatePrice::class => 'createTemplatePrice',
27
    ];
28
29 1
    public function __construct(array $types = [], $defaultClass = null)
30
    {
31 1
        parent::__construct($types, $defaultClass);
32
33 1
        $this->types['TemplatePrice'] = TemplatePrice::class;
34 1
    }
35
36
    public function createTemplatePrice(TemplatePriceDto $dto): TemplatePrice
37
    {
38
        return new TemplatePrice($dto->id, $dto->type, $dto->target, $dto->plan, $dto->prepaid, $dto->price, $dto->subprices);
39
    }
40
}
41