AmountFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 6 1
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