| Conditions | 12 |
| Paths | 14 |
| Total Lines | 33 |
| Code Lines | 22 |
| 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 |
||
| 35 | public function check_page() { |
||
| 36 | if( empty( $_GET['action'] ) || empty( $_GET['type'] ) ) |
||
| 37 | return false; |
||
| 38 | |||
| 39 | $action = sanitize_text_field( $_GET['action'] ); |
||
|
|
|||
| 40 | $type = sanitize_text_field( !empty( $_GET['type'] ) ? $_GET['type'] : '' ); |
||
| 41 | |||
| 42 | if ( !isset( $_GET['service_id'] ) ) return false; |
||
| 43 | else $service_id = (int) $_GET['service_id']; |
||
| 44 | if ( isset( $_GET['key'] ) && 0 !== (int) $_GET['key'] ) $key = (int) $_GET['key']; |
||
| 45 | |||
| 46 | if ( 'view' == $action && isset( $service_id ) ) { |
||
| 47 | $service = log_service_class::g()->get_service_by_id( $service_id ); |
||
| 48 | if( $service == null ) |
||
| 49 | return false; |
||
| 50 | $service_name = $service['name']; |
||
| 51 | if ( !empty( $type ) ) { |
||
| 52 | $service_name .= '-' . $type; |
||
| 53 | } |
||
| 54 | |||
| 55 | // Tous les fichiers |
||
| 56 | $list_archive_file = log_archive_class::g()->get_archive_file( $service_name ); |
||
| 57 | if( !empty( $key ) ) { |
||
| 58 | $service_name .= '_' . $key; |
||
| 59 | } |
||
| 60 | |||
| 61 | $count_warning = $this->open_log( $service['name'] . '-warning' ); |
||
| 62 | $count_error = $this->open_log( $service['name'] . '-error' ); |
||
| 63 | $array_data = $this->open_log( $service_name ); |
||
| 64 | |||
| 65 | return array( 'data' => $array_data, 'list_archive_file' => $list_archive_file, 'count_warning' => $count_warning['count'], 'count_error' => $count_error['count'] ); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 73 |
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.