L39 can be rewritten as 

<<?php echo $headerTag . $headerClass; ?>><?php echo $module->title; ?></<?php echo $headerTag; ?>>

or even better (more clear version)

<?php echo '<' . $headerTag . '>' . $module->title . '</' . $headerTag . '>'; ?>

Rest of the code looks great. :)

one more thing if we can include lines L29 to L33 inside if block then we can spare some clock cycles if $module->content is empty.