AmountFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 6
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace B2Binpay;
5
6
/**
7
 * Amount Factory
8
 *
9
 * @package B2Binpay
10
 */
11
class AmountFactory
12
{
13
    /**
14
     * @var Currency
15
     */
16
    private $currency;
17
18 20
    /**
19
     * AmountFactory constructor.
20 20
     *
21 20
     * @param Currency|null $currency
22
     */
23
    public function __construct(Currency $currency = null)
24
    {
25
        $this->currency = $currency ?? new Currency();
26
    }
27
28
    /**
29 13
     * @param string $sum
30
     * @param int|null $iso
31 13
     * @param int|null $pow
32 13
     * @return Amount
33
     */
34 13
    public function create(string $sum, int $iso = null, int $pow = null)
35
    {
36
        $amount = new Amount($this->currency);
37
        $amount->set($sum, $pow, $iso);
38
39
        return $amount;
40
    }
41
}
42