Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
55 | 26 | public static function encodeName(string $name): string |
|
56 | { |
||
57 | 26 | if ('.' === $name) { |
|
58 | 2 | return chr(0); |
|
59 | } |
||
60 | |||
61 | 24 | $name = rtrim($name, '.').'.'; |
|
62 | 24 | $res = ''; |
|
63 | |||
64 | 24 | foreach (explode('.', $name) as $label) { |
|
65 | 24 | $res .= chr(strlen($label)).$label; |
|
66 | } |
||
67 | |||
68 | 24 | return $res; |
|
69 | } |
||
70 | |||
97 |
If you suppress an error, we recommend checking for the error condition explicitly: