MoneyFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Adsmurai\Currency;
6
7
use Adsmurai\Currency\Contracts\Money as MoneyContract;
8
use Adsmurai\Currency\Contracts\MoneyFactory as MoneyFactoryContract;
9
use Adsmurai\Currency\Contracts\Currency as CurrencyContract;
10
use Litipk\BigNumbers\Decimal;
11
12
final class MoneyFactory implements MoneyFactoryContract
13
{
14
    /** @var CurrencyContract */
15
    private $currency;
16
17 4
    public function __construct(CurrencyContract $currency)
18
    {
19 4
        $this->currency = $currency;
20 4
    }
21
22 1
    public function buildFromFloat(float $amount): MoneyContract
23
    {
24 1
        return Money::fromFloat($amount, $this->currency);
25
    }
26
27 1
    public function buildFromFractionalUnits(int $amount): MoneyContract
28
    {
29 1
        return Money::fromFractionalUnits($amount, $this->currency);
30
    }
31
32 1
    public function buildFromString(string $amount): MoneyContract
33
    {
34 1
        return Money::fromString($amount, $this->currency);
35
    }
36
37 1
    public function buildFromDecimal(Decimal $amount): MoneyContract
38
    {
39 1
        return Money::fromDecimal($amount, $this->currency);
40
    }
41
}
42