CommerceGuys\Addressing\Formatter\DefaultFormatter::cleanupOutput PHP Method

cleanupOutput() protected method

Removes empty lines, leading punctuation, excess whitespace.
protected cleanupOutput ( string $output ) : string
$output string The output that needs cleanup.
return string The cleaned up output.
    protected function cleanupOutput($output)
    {
        $lines = explode("\n", $output);
        foreach ($lines as $index => $line) {
            $line = trim(preg_replace('/^[-,]+/', '', $line, 1));
            $line = preg_replace('/\\s\\s+/', ' ', $line);
            $lines[$index] = $line;
        }
        // Remove empty lines.
        $lines = array_filter($lines);
        return implode("\n", $lines);
    }