| Conditions | 5 |
| Paths | 4 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public static function generate($message = null, \CMain $APPLICATION = null) |
||
| 33 | { |
||
| 34 | if (null === $APPLICATION) { |
||
| 35 | $APPLICATION = $GLOBALS['APPLICATION']; |
||
| 36 | } |
||
| 37 | |||
| 38 | if ($ex = $APPLICATION->GetException()) { |
||
| 39 | throw new static($message ? $message . ': ' . $ex->GetString() : $ex->GetString()); |
||
| 40 | } else { |
||
| 41 | throw new static($message ? $message : 'Unknown exception'); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: