Completed
Push — master ( dbaf03...a19a70 )
by Andrii
14:13
created

PriceRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A create() 0 9 1
1
<?php
2
3
namespace hiqdev\billing\hiapi\plan;
4
5
use hiapi\components\ConnectionInterface;
6
use hiqdev\php\billing\type\Type;
7
use hiqdev\php\billing\target\Target;
8
use hiqdev\php\billing\customer\PriceFactoryInterface;
9
use Money\Money;
10
11
class PriceRepository extends \hiapi\repositories\BaseRepository
12
{
13
    /**
14
     * @var PriceFactoryInterface
15
     */
16
    protected $factory;
17
18
    public function __construct(
19
        ConnectionInterface $db,
20
        PriceFactoryInterface $factory,
21
        array $config = []
22
    ) {
23
        parent::__construct($config);
24
25
        $this->db = $db;
26
        $this->factory = $factory;
27
    }
28
29
    public function create(array $row)
30
    {
31
        $row['type'] = $this->createEntity(Type::class, $row['type']);
32
        $row['target'] = $this->createEntity(Target::class, $row['target']);
33
        $currency = new Currency(strtoupper($row['price']['currency']));
34
        $row['price'] = new Money($row['price']['amount'], $currency);
35
36
        return parent::create($row);
37
    }
38
39
}
40