| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 6 | public static function zeroFill($value = '', $length = 0, $fillSide = self::FILL_LEFT) |
|
| 23 | { |
||
| 24 | 6 | $valueLength = strlen($value); |
|
| 25 | |||
| 26 | 6 | if ($valueLength == $length) { |
|
| 27 | 1 | return $value; |
|
| 28 | } |
||
| 29 | |||
| 30 | 5 | if ($valueLength > $length) { |
|
| 31 | 1 | throw new \InvalidArgumentException(sprintf( |
|
| 32 | 1 | 'The given value (%s) is invalid', |
|
| 33 | 1 | $value |
|
| 34 | )); |
||
| 35 | } |
||
| 36 | |||
| 37 | 4 | return str_pad($value, $length, 0, $fillSide); |
|
| 38 | } |
||
| 39 | } |
||
| 40 |