Completed
Push — master ( 0c702e...f32b73 )
by P.R.
01:15
created

WhitespaceCleaner.clean()   A

Complexity

Conditions 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
1
class WhitespaceCleaner:
2
    """
3
    Utility class for cleaning whitespace from strings.
4
    """
5
6
    # ------------------------------------------------------------------------------------------------------------------
7
    @staticmethod
8
    def clean(string):
9
        """
10
        Prunes whitespace from a string.
11
12
        :param str string: The string.
13
14
        :rtype str:
15
        """
16
        # Return empty input immediately.
17
        if not string:
18
            return string
19
20
        return string.replace('  ', ' ').strip()
21
22
# ----------------------------------------------------------------------------------------------------------------------
23