Completed
Branch FET-10619-money-entity (77ea92)
by
unknown
102:26 queued 91:05
created

InternationalMoneyFormatter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 7 1
1
<?php
2
3
namespace EventEspresso\core\services\currency\formatters;
4
5
use EventEspresso\core\domain\values\currency\Currency;
6
7
defined('EVENT_ESPRESSO_VERSION') || exit;
8
9
10
11
/**
12
 * Class InternationalMoneyFormatter
13
 * appends the currency code wrapped in a span tag to the end of the supplied amount
14
 *
15
 * @package       Event Espresso
16
 * @author        Brent Christensen
17
 * @since         $VID:$
18
 */
19
class InternationalMoneyFormatter 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
        $currency_code = $currency->code();
32
        // remove currency code if already added
33
        $money_amount = str_replace($currency_code, '', $money_amount);
34
        return trim($money_amount) . ' <span class="currency-code">(' . $currency_code . ')</span>';
35
    }
36
37
38
39
}
40