| Conditions | 7 |
| Paths | 9 |
| Total Lines | 18 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public static function mysql_format() |
||
| 15 | { |
||
| 16 | //phpcs:enable |
||
| 17 | $args = func_get_args(); |
||
| 18 | $length = count($args); |
||
| 19 | if ($args && 0 < $length && ($number = $args[0]) != null) { |
||
|
|
|||
| 20 | $decimals = 1 < $length ? $args[1] : 0; |
||
| 21 | $culture = 2 < $length ? $args[2] : 'en_US'; |
||
| 22 | $pattern = '#,##0'; |
||
| 23 | if ($decimals > 0) { |
||
| 24 | $pattern = $pattern.'.'; |
||
| 25 | $base = strlen($pattern); |
||
| 26 | $decimals = $base + $decimals; |
||
| 27 | $pattern = str_pad($pattern, $decimals, '0', STR_PAD_RIGHT); |
||
| 28 | } |
||
| 29 | $formatter = new NumberFormatter($culture, NumberFormatter::PATTERN_DECIMAL, $pattern); |
||
| 30 | |||
| 31 | return $formatter->format($number); |
||
| 32 | } |
||
| 48 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.