| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| 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 |
||
| 125 | private function registerCallbackHandlers( $config ) { |
||
| 126 | |||
| 127 | $applicationFactory = ApplicationFactory::getInstance(); |
||
| 128 | |||
| 129 | $appFactory = new AppFactory( |
||
| 130 | $config, |
||
| 131 | $applicationFactory->getCache() |
||
| 132 | ); |
||
| 133 | |||
| 134 | $appFactory->setLogger( |
||
| 135 | $applicationFactory->getMediaWikiLogger( 'sesp' ) |
||
| 136 | ); |
||
| 137 | |||
| 138 | $propertyRegistry = new PropertyRegistry( |
||
| 139 | $appFactory |
||
| 140 | ); |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::Property::initProperties |
||
| 144 | */ |
||
| 145 | $this->handlers['SMW::Property::initProperties'] = function ( $registry ) use ( $propertyRegistry ) { |
||
| 146 | |||
| 147 | $propertyRegistry->register( |
||
| 148 | $registry |
||
| 149 | ); |
||
| 150 | |||
| 151 | return true; |
||
| 152 | }; |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::SQLStore::AddCustomFixedPropertyTables |
||
| 156 | */ |
||
| 157 | $this->handlers['SMW::SQLStore::AddCustomFixedPropertyTables'] = function( array &$customFixedProperties, &$fixedPropertyTablePrefix ) use( $propertyRegistry ) { |
||
| 158 | |||
| 159 | $propertyRegistry->registerFixedProperties( |
||
| 160 | $customFixedProperties, |
||
| 161 | $fixedPropertyTablePrefix |
||
| 162 | ); |
||
| 163 | |||
| 164 | return true; |
||
| 165 | }; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMWStore::updateDataBefore |
||
| 169 | */ |
||
| 170 | $this->handlers['SMWStore::updateDataBefore'] = function ( $store, $semanticData ) use ( $appFactory ) { |
||
| 171 | |||
| 172 | $extraPropertyAnnotator = new ExtraPropertyAnnotator( |
||
| 173 | $appFactory |
||
| 174 | ); |
||
| 175 | |||
| 176 | $extraPropertyAnnotator->addAnnotation( $semanticData ); |
||
| 177 | |||
| 178 | return true; |
||
| 179 | }; |
||
| 180 | } |
||
| 181 | |||
| 183 |