| Conditions | 3 |
| Paths | 3 |
| Total Lines | 30 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 3.0416 |
| 1 | <?php |
||
| 37 | 1 | public static function getOfflineMessage($external, $message = null) |
|
| 38 | { |
||
| 39 | 1 | global $dontUseDbCulprit, $dontUseDbReason, $baseurl; |
|
| 40 | |||
| 41 | 1 | $smarty = new Smarty(); |
|
| 42 | 1 | $smarty->assign("baseurl", $baseurl); |
|
| 43 | 1 | $smarty->assign("toolversion", Environment::getToolVersion()); |
|
| 44 | |||
| 45 | 1 | header("HTTP/1.1 503 Service Unavailable"); |
|
| 46 | |||
| 47 | 1 | if ($external) { |
|
| 48 | 1 | return $smarty->fetch("offline/external.tpl"); |
|
| 49 | } |
||
| 50 | else { |
||
| 51 | 1 | $hideCulprit = true; |
|
| 52 | |||
| 53 | // Use the provided message if possible |
||
| 54 | 1 | if ($message === null) { |
|
| 55 | $hideCulprit = false; |
||
| 56 | $message = $dontUseDbReason; |
||
| 57 | } |
||
| 58 | |||
| 59 | 1 | $smarty->assign("hideCulprit", $hideCulprit); |
|
| 60 | 1 | $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit); |
|
| 61 | 1 | $smarty->assign("dontUseDbReason", $message); |
|
| 62 | 1 | $smarty->assign("alerts", array()); |
|
| 63 | |||
| 64 | 1 | return $smarty->fetch("offline/internal.tpl"); |
|
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state