| Conditions | 7 |
| Paths | 7 |
| Total Lines | 56 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| 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 |
||
| 78 | public function admin_notice_tld_test() { |
||
| 79 | $screen = get_current_screen(); |
||
|
|
|||
| 80 | |||
| 81 | if ( null === $screen ) { |
||
|
1 ignored issue
–
show
|
|||
| 82 | return; |
||
| 83 | } |
||
| 84 | |||
| 85 | if ( 'pronamic_gateway' !== $screen->id ) { |
||
| 86 | return; |
||
| 87 | } |
||
| 88 | |||
| 89 | $host = wp_parse_url( home_url( '/' ), PHP_URL_HOST ); |
||
| 90 | |||
| 91 | if ( is_array( $host ) ) { |
||
| 92 | return; |
||
| 93 | } |
||
| 94 | |||
| 95 | if ( '.test' !== substr( $host, -5 ) ) { |
||
| 96 | return; |
||
| 97 | } |
||
| 98 | |||
| 99 | $post_id = get_the_ID(); |
||
| 100 | |||
| 101 | if ( empty( $post_id ) ) { |
||
| 102 | return; |
||
| 103 | } |
||
| 104 | |||
| 105 | $gateway_id = get_post_meta( $post_id, '_pronamic_gateway_id', true ); |
||
| 106 | |||
| 107 | if ( 'rabobank-omnikassa-2' !== $gateway_id ) { |
||
| 108 | return; |
||
| 109 | } |
||
| 110 | |||
| 111 | $class = 'notice notice-error'; |
||
| 112 | $message = sprintf( |
||
| 113 | /* translators: 1: Pronamic Pay, 2: Documentation link, 3: <code>.test</code> */ |
||
| 114 | __( '%1$s — <a href="%2$s">OmniKassa 2 does not accept payments from %3$s environments</a>.', 'pronamic_ideal' ), |
||
| 115 | sprintf( |
||
| 116 | '<strong>%s</strong>', |
||
| 117 | __( 'Pronamic Pay', 'pronamic_ideal' ) |
||
| 118 | ), |
||
| 119 | 'https://github.com/wp-pay-gateways/omnikassa-2/tree/develop/documentation#merchantreturnurl-is-not-a-valid-web-address', |
||
| 120 | '<code>.test</code>' |
||
| 121 | ); |
||
| 122 | |||
| 123 | printf( |
||
| 124 | '<div class="%1$s"><p>%2$s</p></div>', |
||
| 125 | esc_attr( $class ), |
||
| 126 | wp_kses( |
||
| 127 | $message, |
||
| 128 | array( |
||
| 129 | 'a' => array( |
||
| 130 | 'href' => true, |
||
| 131 | ), |
||
| 132 | 'code' => array(), |
||
| 133 | 'strong' => array(), |
||
| 134 | ) |
||
| 172 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.