TextFormatter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 1
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A currencyStringToFloat() 0 14 1
1
<?php
2
namespace App\Lib\Helpers;
3
4
5
/**
6
 * Class TextFormatter
7
 * @package App\Lib\Helpers
8
 */
9
class TextFormatter
10
{
11
12
    /**
13
     * @param $currencyString
14
     * @return float
15
     */
16
    public static function currencyStringToFloat($currencyString){
17
		//currency is always in this format € 550
18
19
		return floatval(
20
			str_replace(
21
				',',
22
				'',
23
				RegExp::getFirstMatch(
24
					'/([+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]{2})?)/',
25
					$currencyString
26
				)
27
			)
28
		);
29
	}
30
31
}