| Conditions | 7 |
| Paths | 6 |
| Total Lines | 66 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 94 | public static function onExtensionFunction() { |
||
| 95 | |||
| 96 | if ( !defined( 'SMW_VERSION' ) ) { |
||
| 97 | if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
||
| 98 | die( "\nThe 'Semantic Breadcrumb Links' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" ); |
||
| 99 | } else { |
||
| 100 | die( '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticBreadcrumbLinks/">Semantic Breadcrumb Links</a> extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be installed and enabled.<br />' ); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | // Default values are defined at this point to ensure |
||
| 105 | // NS contants are specified prior |
||
| 106 | $defaultPropertySearchPatternByNamespace = [ |
||
| 107 | NS_CATEGORY => [ |
||
| 108 | '_SUBC', |
||
| 109 | '_SUBC', |
||
| 110 | '_SUBC' |
||
| 111 | ], |
||
| 112 | SMW_NS_PROPERTY => [ |
||
| 113 | '_SUBP', |
||
| 114 | '_SUBP', |
||
| 115 | '_SUBP' |
||
| 116 | ], |
||
| 117 | NS_MAIN => [ |
||
| 118 | SBL_PROP_PARENTPAGE, |
||
| 119 | SBL_PROP_PARENTPAGE, |
||
| 120 | SBL_PROP_PARENTPAGE |
||
| 121 | ], |
||
| 122 | NS_HELP => [ |
||
| 123 | SBL_PROP_PARENTPAGE, |
||
| 124 | SBL_PROP_PARENTPAGE, |
||
| 125 | SBL_PROP_PARENTPAGE |
||
| 126 | ] |
||
| 127 | ]; |
||
| 128 | |||
| 129 | // Cover legacy settings |
||
| 130 | $deprecationNotices = []; |
||
| 131 | |||
| 132 | if ( isset( $GLOBALS['egSBLBreadcrumbTrailStyleClass'] ) ) { |
||
| 133 | $GLOBALS['sblgBreadcrumbTrailStyleClass'] = $GLOBALS['egSBLBreadcrumbTrailStyleClass']; |
||
| 134 | $deprecationNotices['replacement']['egSBLBreadcrumbTrailStyleClass'] = 'sblgBreadcrumbTrailStyleClass'; |
||
| 135 | } |
||
| 136 | |||
| 137 | if ( $deprecationNotices !== [] && !isset( $GLOBALS['smwgDeprecationNotices']['sbl'] ) ) { |
||
| 138 | $GLOBALS['smwgDeprecationNotices']['sbl'] = [ 'replacement' => $deprecationNotices['replacement'] ]; |
||
| 139 | } |
||
| 140 | |||
| 141 | $configuration = [ |
||
| 142 | 'hideSubpageParent' => $GLOBALS['egSBLPageTitleToHideSubpageParent'], |
||
| 143 | 'breadcrumbTrailStyleClass' => $GLOBALS['sblgBreadcrumbTrailStyleClass'], |
||
| 144 | 'breadcrumbDividerStyleClass' => $GLOBALS['egSBLBreadcrumbDividerStyleClass'], |
||
| 145 | 'tryToFindClosestDescendant' => $GLOBALS['egSBLTryToFindClosestDescendant'], |
||
| 146 | 'useSubpageFinderFallback' => $GLOBALS['egSBLUseSubpageFinderFallback'], |
||
| 147 | 'enabledSubpageParentAnnotation' => $GLOBALS['egSBLEnabledSubpageParentAnnotation'], |
||
| 148 | 'disableTranslationSubpageAnnotation' => $GLOBALS['egSBLDisableTranslationSubpageAnnotation'], |
||
| 149 | 'wgNamespacesWithSubpages' => $GLOBALS['wgNamespacesWithSubpages'], |
||
| 150 | 'propertySearchPatternByNamespace' => $GLOBALS['egSBLPropertySearchPatternByNamespace'] + $defaultPropertySearchPatternByNamespace |
||
| 151 | ]; |
||
| 152 | |||
| 153 | $hookRegistry = new HookRegistry( |
||
| 154 | ApplicationFactory::getInstance()->getStore(), |
||
| 155 | new Options( $configuration ) |
||
| 156 | ); |
||
| 157 | |||
| 158 | $hookRegistry->register(); |
||
| 159 | } |
||
| 160 | |||
| 171 |