GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DecimalMoneyFormatter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handler() 0 7 1
A directive() 0 6 1
1
<?php
2
3
namespace ProtoneMedia\LaravelMixins\Blade;
4
5
use Illuminate\Support\Facades\Blade;
6
use Money\Currencies\ISOCurrencies;
7
use Money\Formatter\DecimalMoneyFormatter as BaseFormatter;
8
use Money\Money;
9
10
class DecimalMoneyFormatter
11
{
12
    use BladeDirectiveHelpers;
13
14
    /**
15
     * Calls the format() method on the DecimalMoneyFormatter with the given
16
     * amount of ccents and currency code.
17
     *
18
     * @param integer $cents
19
     * @param string $code
20
     * @return string
21
     */
22
    public static function handler(int $cents, string $code): string
23
    {
24
        $formatter = new BaseFormatter(new ISOCurrencies);
25
26
        $money = Money::$code($cents);
27
28
        return $formatter->format($money);
29
    }
30
31
    /**
32
     * Registers a handler for the money formatter.
33
     *
34
     * @param string $name
35
     * @param string $code
36
     * @return void
37
     */
38
    public static function directive(string $name = 'decimals', string $code = 'EUR')
39
    {
40
        Blade::directive($name, function ($expression) use ($code) {
41
            $parts = static::parseExpression($expression, [1 => "'{$code}'"]);
42
43
            return "<?php echo \ProtoneMedia\LaravelMixins\Blade\DecimalMoneyFormatter::handler($parts[0], $parts[1]) ?>";
44
        });
45
    }
46
}
47