| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| 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 |
||
| 44 | __( 'Setup Jetpack', 'jetpack' ), |
||
| 45 | esc_url( \Jetpack::init()->build_connect_url( true, false, 'pre-connection-jitm-upload' ) ) |
||
| 46 | ), |
||
| 47 | ( new Message( 'jpsetup-widgets' ) ) |
||
| 48 | ->message_path( '/wp:widgets:admin_notices/' ) |
||
| 49 | ->show( |
||
| 50 | __( 'Looking for even more widgets?', 'jetpack' ), |
||
| 51 | __( 'Setup Jetpack for great additional widgets like business hours and maps.', 'jetpack' ) |
||
| 52 | ) |
||
| 53 | ->with_cta( |
||
| 54 | __( 'Setup Jetpack', 'jetpack' ), |
||
| 55 | esc_url( \Jetpack::init()->build_connect_url( true, false, 'pre-connection-jitm-widgets' ) ) |
||
| 56 | ), |
||
| 57 | ); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Gets the top messages |
||
| 62 | * |
||
| 63 | * @param string $message_path Message path. |
||
| 64 | * |
||
| 65 | * @return array Rendered messages. |
||
| 66 | */ |
||
| 67 | public function render_messages( $message_path ) { |
||
| 68 | $rules = $this->preconnection_rules(); |
||
| 69 | |||
| 70 | $rendered_rules = array(); |
||
| 71 | |||
| 72 | foreach ( $rules as $rule ) { |
||
| 73 | |||
| 74 | if ( ! preg_match( $rule->message_path_regex, $message_path ) ) { |
||
|
|
|||
| 75 | continue; |
||
| 76 | } |
||
| 77 | |||
| 78 | // TODO: add partner filter here. |
||
| 79 | |||
| 80 | $rendered_rules[] = $rule->render(); |
||
| 81 | } |
||
| 82 | |||
| 83 | return $rendered_rules; |
||
| 84 | } |
||
| 85 | |||
| 86 | } |
||
| 87 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.