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