Test Failed
Push — master ( 646e1f...19314b )
by Gabriel
02:47
created

Money   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fromFloat() 0 4 1
A currency() 0 4 2
A currencyDefault() 0 3 1
A create() 0 4 1
1
<?php
2
3
namespace ByTIC\Money\Utility;
4
5
use Money\Currency;
6
7
/**
8
 * Class Money
9
 * @package ByTIC\Money\Utility
10
 */
11
class Money
12
{
13
    /**
14
     * @param $value
15
     * @param null $currency
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $currency is correct as it would always require null to be passed?
Loading history...
16
     */
17
    public static function fromFloat($value, $currency = null)
18
    {
19
        $currency = static::currency($currency);
20
        return new \Money\Money($value*100, $currency);
21
    }
22
23
    /**
24
     * @param $value
25
     * @param null $currency
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $currency is correct as it would always require null to be passed?
Loading history...
26
     */
27
    public static function create($value, $currency = null)
28
    {
29
        $currency = static::currency($currency);
30
        return new \Money\Money($value, $currency);
31
    }
32
33
    /**
34
     * @param $code
35
     * @return Currency
36
     */
37
    public static function currency($code = null)
38
    {
39
        $code = $code ?: static::currencyDefault();
40
        return new Currency($code);
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public static function currencyDefault()
47
    {
48
        return 'RON';
49
    }
50
}