Completed
Branch FET-10619-money-entity (c56734)
by
unknown
157:04 queued 143:03
created

CurrencySignMoneyFormatter::format()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 2
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\services\currency;
4
5
use EventEspresso\core\entities\money\Currency;
6
7
defined('EVENT_ESPRESSO_VERSION') || exit;
8
9
10
11
/**
12
 * Class CurrencySignMoneyFormatter
13
 * adds currency sign to the supplied amount
14
 *
15
 * @package       Event Espresso
16
 * @author        Brent Christensen
17
 * @since         $VID:$
18
 */
19
class CurrencySignMoneyFormatter implements MoneyFormatter
20
{
21
22
23
24
    /**
25
     * @param string   $money_amount
26
     * @param Currency $currency
27
     * @return string
28
     */
29
    public function format($money_amount, Currency $currency)
30
    {
31
        // add currency sign
32
        if ($currency->signB4()) {
33
            if ($money_amount >= 0) {
34
                return $currency->sign() . $money_amount;
35
            }
36
            return '-' . $currency->sign() . str_replace('-', '', $money_amount);
37
        }
38
        return $money_amount . $currency->sign();
39
    }
40
}
41
// End of file CurrencySignMoneyFormatter.php
42
// Location: EventEspresso\core\services\currency/CurrencySignMoneyFormatter.php