| Conditions | 3 |
| Paths | 4 |
| Total Lines | 10 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3.0261 |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | 47 | public static function singleton($id = null) |
|
|
|
|||
| 12 | { |
||
| 13 | 47 | if ($id != null) { |
|
| 14 | 4 | $GLOBALS['intraface_doctrine_intranet_id'] = intval($id); |
|
| 15 | 4 | } |
|
| 16 | 47 | if (empty($GLOBALS['intraface_doctrine_intranet_id'])) { |
|
| 17 | throw new Exception('An intranet id was not set!'); |
||
| 18 | } |
||
| 19 | 47 | return new Intraface_Doctrine_Intranet($GLOBALS['intraface_doctrine_intranet_id']); |
|
| 20 | } |
||
| 21 | |||
| 27 |
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: