| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | * @since 1.0 |
||
| 31 | * |
||
| 32 | * @return self |
||
| 33 | */ |
||
| 34 | 6 | public static function newFromGlobals() { |
|
|
|
|||
| 35 | 6 | $GLOBALS['sucgCachePrefix'] = $GLOBALS['wgCachePrefix'] === false ? wfWikiID() : $GLOBALS['wgCachePrefix']; |
|
| 36 | |||
| 37 | $configuration = array( |
||
| 38 | 6 | 'tooltipRequestCacheTTL' => $GLOBALS['sucgTooltipRequestCacheLifetime'], |
|
| 39 | 6 | 'cachePrefix' => $GLOBALS['sucgCachePrefix'], |
|
| 40 | 6 | 'enabledNamespaceWithTemplate' => $GLOBALS['sucgEnabledNamespaceWithTemplate'], |
|
| 41 | 6 | 'enabledForAnonUsers' => $GLOBALS['sucgEnabledForAnonUser'], |
|
| 42 | 6 | 'backendParserCacheLifetime' => $GLOBALS['sucgBackendParserCacheLifetime'], |
|
| 43 | 6 | 'backendParserCacheType' => $GLOBALS['sucgBackendParserCacheType'] |
|
| 44 | 6 | ); |
|
| 45 | |||
| 46 | 6 | return new self( $configuration ); |
|
| 88 |
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: