| Conditions | 12 |
| Paths | 19 |
| Total Lines | 32 |
| Code Lines | 24 |
| 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 |
||
| 66 | public function autoload( $class ) { |
||
| 67 | $class = strtolower( $class ); |
||
| 68 | |||
| 69 | if ( 0 !== strpos( $class, 'gd_' ) ) { |
||
| 70 | return; |
||
| 71 | } |
||
| 72 | |||
| 73 | $file = $this->get_file_name_from_class( $class ); |
||
| 74 | $path = ''; |
||
| 75 | |||
| 76 | if ( strpos( $class, 'wc_addons_gateway_' ) === 0 ) { |
||
| 77 | $path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 18 ) . '/'; |
||
| 78 | } elseif ( strpos( $class, 'gd_gateway_' ) === 0 ) { |
||
| 79 | $path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 11 ) . '/'; |
||
| 80 | } elseif ( strpos( $class, 'gd_shipping_' ) === 0 ) { |
||
| 81 | $path = $this->include_path . 'shipping/' . substr( str_replace( '_', '-', $class ), 12 ) . '/'; |
||
| 82 | } elseif ( strpos( $class, 'gd_shortcode_' ) === 0 ) { |
||
| 83 | $path = $this->include_path . 'shortcodes/'; |
||
| 84 | } elseif ( strpos( $class, 'gd_meta_box' ) === 0 ) { |
||
| 85 | $path = $this->include_path . 'admin/meta-boxes/'; |
||
| 86 | } elseif ( strpos( $class, 'gd_admin' ) === 0 ) { |
||
| 87 | $path = $this->include_path . 'admin/'; |
||
| 88 | } elseif ( strpos( $class, 'gd_payment_token_' ) === 0 ) { |
||
| 89 | $path = $this->include_path . 'payment-tokens/'; |
||
| 90 | } elseif ( strpos( $class, 'gd_log_handler_' ) === 0 ) { |
||
| 91 | $path = $this->include_path . 'log-handlers/'; |
||
| 92 | } |
||
| 93 | |||
| 94 | if ( empty( $path ) || ! $this->load_file( $path . $file ) ) { |
||
| 95 | $this->load_file( $this->include_path . $file ); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | } |
||
| 101 |