EXSISTING CODE /** * Identify the space indention from the first line and remove this indention * from all lines * * @param string $body * * @return string */ protected static function clearBodyIndention($body) { if (empty($body)) { return $body; } $lines = explode("\n", $body); $indention = str_replace(trim($lines[1]), '', $lines[1]); foreach ($lines as $key => $line) { if (substr($line, 0, strlen($indention)) == $indention) { $lines[$key] = substr($line, strlen($indention)); } } $body = implode("\n", $lines); return $body; } POSSIBLE FIX /** * Identify the space indention from the first line and remove this indention * from all lines * * @param string $body * * @return string */ protected static function clearBodyIndention($body) { if (empty($body)) { return $body; } $lines = explode("\n", $body); $firstLine = array_shift(array_filter($lines)); $indention = str_replace(trim($firstLine), '', $firstLine); foreach ($lines as $key => $line) { if (substr($line, 0, strlen($indention)) == $indention) { $lines[$key] = substr($line, strlen($indention)); } } $body = implode("\n", $lines); return $body; }