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

PriceRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 3
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