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

Money::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
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
}