Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2.032 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | 1 | protected function formatCurrency() |
|
34 | { |
||
35 | // Remove any non-digits from the input. |
||
36 | //TODO: Validate that any non-digits are valid currency characters. |
||
37 | 1 | $input = preg_filter('/^\D./', '', $this->input); |
|
38 | |||
39 | 1 | if (empty($input)) { |
|
40 | return true; |
||
41 | } |
||
42 | |||
43 | // Check that the remainder of the input matches an expected currency format. |
||
44 | // This regex is provided by Tim Pietzcker here: http://stackoverflow.com/a/4983648. |
||
45 | 1 | return (true == preg_match('/\b\d{1,3}(?:,?\d{3})*(?:\.\d{2})?\b/', $input)); |
|
1 ignored issue
–
show
|
|||
46 | } |
||
47 | } |
||
48 |