Passed
Push — master ( a8b983...5b3176 )
by Adrien
10:48
created

Utility   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10
c 2
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sanitizeRichText() 0 5 1
A getFormattedBalance() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application;
6
7
use Application\Model\Order;
8
use Money\Currencies\ISOCurrencies;
9
use Money\Formatter\DecimalMoneyFormatter;
10
11
abstract class Utility
12
{
13 1
    public static function sanitizeRichText(string $string): string
14
    {
15 1
        $sanitized = strip_tags($string, ['ul', 'ol', 'li', 'p', 'br', 'sup', 'sub', 'a', 'strong', 'em']);
1 ignored issue
show
Bug introduced by
array('ul', 'ol', 'li', ...', 'a', 'strong', 'em') of type array<integer,string> is incompatible with the type string expected by parameter $allowable_tags of strip_tags(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
        $sanitized = strip_tags($string, /** @scrutinizer ignore-type */ ['ul', 'ol', 'li', 'p', 'br', 'sup', 'sub', 'a', 'strong', 'em']);
Loading history...
16
17 1
        return $sanitized;
18
    }
19
20 7
    public static function getFormattedBalance($object): string
21
    {
22 7
        $money = $object->getBalanceEUR()->isZero() ? $object->getBalanceCHF() : $object->getBalanceEUR();
23 7
        $currencies = new ISOCurrencies();
24 7
        $moneyFormatter = new DecimalMoneyFormatter($currencies);
25
26 7
        return $moneyFormatter->format($money) . ' ' . $money->getCurrency()->getCode();
27
    }
28
}
29