| Conditions | 4 | 
| Paths | 8 | 
| Total Lines | 55 | 
| Code Lines | 24 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 0 | 
| CRAP Score | 20 | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 26 | public static function exceptionHandler(Throwable $exception)  | 
            ||
| 27 |     { | 
            ||
| 28 | /** @global $siteConfiguration SiteConfiguration */  | 
            ||
| 29 | global $siteConfiguration;  | 
            ||
| 30 | |||
| 31 | $errorDocument = <<<HTML  | 
            ||
| 32 | <!DOCTYPE html>  | 
            ||
| 33 | <html lang="en"><head>  | 
            ||
| 34 | <meta charset="utf-8">  | 
            ||
| 35 | <title>Oops! Something went wrong!</title>  | 
            ||
| 36 | <meta name="viewport" content="width=device-width, initial-scale=1.0">  | 
            ||
| 37 | <link href="{$siteConfiguration->getBaseUrl()}/resources/generated/bootstrap-main.css" rel="stylesheet"> | 
            ||
| 38 | <style>  | 
            ||
| 39 |   body { | 
            ||
| 40 | padding-top: 60px;  | 
            ||
| 41 | }  | 
            ||
| 42 | </style>  | 
            ||
| 43 | </head><body><div class="container">  | 
            ||
| 44 | <h1>Oops! Something went wrong!</h1>  | 
            ||
| 45 | <p>We'll work on fixing this for you, so why not come back later?</p>  | 
            ||
| 46 | <p class="muted">If our trained monkeys ask, tell them this error ID: <code>$1$</code></p>  | 
            ||
| 47 | $2$  | 
            ||
| 48 | </div></body></html>  | 
            ||
| 49 | HTML;  | 
            ||
| 50 | |||
| 51 | list($errorData, $errorId) = self::logExceptionToDisk($exception, $siteConfiguration, true);  | 
            ||
| 52 | |||
| 53 | // clear and discard any content that's been saved to the output buffer  | 
            ||
| 54 |         if (ob_get_level() > 0) { | 
            ||
| 55 | ob_end_clean();  | 
            ||
| 56 | }  | 
            ||
| 57 | |||
| 58 | // push error ID into the document.  | 
            ||
| 59 |         $message = str_replace('$1$', $errorId, $errorDocument); | 
            ||
| 60 | |||
| 61 |         if ($siteConfiguration->getDebuggingTraceEnabled()) { | 
            ||
| 62 | ob_start();  | 
            ||
| 63 | var_dump($errorData);  | 
            ||
| 
                                                                                                    
                         1 ignored issue 
                            –
                            show
                         | 
                |||
| 64 | $textErrorData = ob_get_contents();  | 
            ||
| 65 | ob_end_clean();  | 
            ||
| 66 | |||
| 67 |             $message = str_replace('$2$', $textErrorData, $message); | 
            ||
| 68 | }  | 
            ||
| 69 |         else { | 
            ||
| 70 |             $message = str_replace('$2$', "", $message); | 
            ||
| 71 | }  | 
            ||
| 72 | |||
| 73 | // While we *shouldn't* have sent headers by now due to the output buffering, PHPUnit does weird things.  | 
            ||
| 74 | // This is "only" needed for the tests, but it's a good idea to wrap this anyway.  | 
            ||
| 75 |         if (!headers_sent()) { | 
            ||
| 76 |             header('HTTP/1.1 500 Internal Server Error'); | 
            ||
| 77 | }  | 
            ||
| 78 | |||
| 79 | // output the document  | 
            ||
| 80 | print $message;  | 
            ||
| 81 | }  | 
            ||
| 152 |