Completed
Push — master ( f8a59f...796b11 )
by Dmitry
02:31
created

PriceFactory::createByDto()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 7
nc 1
nop 1
crap 2
1
<?php
2
3
4
namespace hiqdev\billing\hiapi\repositories;
5
6
use hiqdev\billing\hiapi\models\Price;
7
use hiqdev\php\billing\SinglePrice;
8
use hiqdev\php\billing\Target;
9
use hiqdev\php\billing\Type;
10
use hiqdev\php\units\Quantity;
11
use Money\Currency;
12
use Money\Money;
13
14
class PriceFactory
15
{
16
    protected $class = Price::class;
17
18
    public function createByDto(PriceCreationDto $dto)
19
    {
20
        return new SinglePrice(
21
            $dto->id,
22
            new Target($dto->target_id, new Type($dto->target_type_id, $dto->target_type_name)),
23
            new Type($dto->type_id, $dto->type),
24
            Quantity::create($dto->unit, $dto->quantity),
25
            new Money($dto->price, new Currency($dto->currency))
26
        );
27
    }
28
}
29