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

PriceFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 7
dl 0
loc 15
ccs 0
cts 4
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createByDto() 0 10 1
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