Passed
Branch master (17b603)
by P.R.
01:31
created

WhitespaceCleaner.clean()   A

Complexity

Conditions 2

Size

Total Lines 14
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 5
nop 1
dl 0
loc 14
ccs 0
cts 5
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
"""
2
ETLT
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
9
10
class WhitespaceCleaner:
11
    """
12
    Utility class for cleaning whitespace from strings.
13
    """
14
15
    # ------------------------------------------------------------------------------------------------------------------
16
    @staticmethod
17
    def clean(string):
18
        """
19
        Prunes whitespace from a string.
20
21
        :param str string: The string.
22
23
        :rtype: str
24
        """
25
        # Return empty input immediately.
26
        if not string:
27
            return string
28
29
        return string.replace('  ', ' ').strip()
30
31
# ----------------------------------------------------------------------------------------------------------------------
32