| Conditions | 11 |
| Paths | 26 |
| Total Lines | 48 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 96 | protected static function singleton() { |
||
| 97 | global $wgUseTidy, $wgTidyInternal, $wgTidyConf, $wgDebugTidy, $wgTidyConfig, |
||
| 98 | $wgTidyBin, $wgTidyOpts; |
||
| 99 | |||
| 100 | if ( self::$instance === null ) { |
||
| 101 | if ( $wgTidyConfig !== null ) { |
||
| 102 | $config = $wgTidyConfig; |
||
| 103 | } elseif ( $wgUseTidy ) { |
||
| 104 | // b/c configuration |
||
| 105 | $config = [ |
||
| 106 | 'tidyConfigFile' => $wgTidyConf, |
||
| 107 | 'debugComment' => $wgDebugTidy, |
||
| 108 | 'tidyBin' => $wgTidyBin, |
||
| 109 | 'tidyCommandLine' => $wgTidyOpts ]; |
||
| 110 | if ( $wgTidyInternal ) { |
||
| 111 | if ( wfIsHHVM() ) { |
||
| 112 | $config['driver'] = 'RaggettInternalHHVM'; |
||
| 113 | } else { |
||
| 114 | $config['driver'] = 'RaggettInternalPHP'; |
||
| 115 | } |
||
| 116 | } else { |
||
| 117 | $config['driver'] = 'RaggettExternal'; |
||
| 118 | } |
||
| 119 | } else { |
||
| 120 | return false; |
||
| 121 | } |
||
| 122 | switch ( $config['driver'] ) { |
||
| 123 | case 'RaggettInternalHHVM': |
||
| 124 | self::$instance = new MediaWiki\Tidy\RaggettInternalHHVM( $config ); |
||
| 125 | break; |
||
| 126 | case 'RaggettInternalPHP': |
||
| 127 | self::$instance = new MediaWiki\Tidy\RaggettInternalPHP( $config ); |
||
| 128 | break; |
||
| 129 | case 'RaggettExternal': |
||
| 130 | self::$instance = new MediaWiki\Tidy\RaggettExternal( $config ); |
||
| 131 | break; |
||
| 132 | case 'Html5Depurate': |
||
| 133 | self::$instance = new MediaWiki\Tidy\Html5Depurate( $config ); |
||
| 134 | break; |
||
| 135 | case 'Html5Internal': |
||
| 136 | self::$instance = new MediaWiki\Tidy\Html5Internal( $config ); |
||
| 137 | break; |
||
| 138 | default: |
||
| 139 | throw new MWException( "Invalid tidy driver: \"{$config['driver']}\"" ); |
||
| 140 | } |
||
| 141 | } |
||
| 142 | return self::$instance; |
||
| 143 | } |
||
| 144 | |||
| 160 |