MoneyFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 30
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildFromFloat() 0 4 1
A buildFromFractionalUnits() 0 4 1
A buildFromString() 0 4 1
A buildFromDecimal() 0 4 1
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