throw an Exception when header is already been sent
replace whitespaces with TABs and only throw exception when Cake is in Debug mode
throw CakeException instead, putting throws tag in the comment
Fix up code formatting and structure for #3998

* Fix the various PHPCS errors.
* Make the logic less complex.
Merge pull request #4106 from cakephp/header-exception

Raise exceptions when headers have been sent