| Conditions | 8 |
| Paths | 14 |
| Total Lines | 53 |
| Code Lines | 25 |
| 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 |
||
| 20 | function wpbo_input_dummy( $lines = 5 ) { |
||
| 21 | |||
| 22 | if( isset( $_GET['wpbo_dummy'] ) && is_numeric( $_GET['wpbo_dummy'] ) ) |
||
| 23 | $lines = $_GET['wpbo_dummy']; |
||
| 24 | |||
| 25 | /* Max conversion rate */ |
||
| 26 | $ratio = 10; |
||
| 27 | |||
| 28 | /* Max conversion added based on max ratio */ |
||
| 29 | $max = ( 20 * $lines ) / 100; |
||
| 30 | |||
| 31 | $args = array( |
||
| 32 | 'post_type' => 'wpbo-popup', |
||
| 33 | 'post_status' => 'publish', |
||
| 34 | 'posts_per_page' => -1, |
||
| 35 | |||
| 36 | ); |
||
| 37 | |||
| 38 | $popups = new WP_Query( $args ); |
||
| 39 | |||
| 40 | if( count( $popups->posts ) >= 1 ) { |
||
| 41 | |||
| 42 | foreach( $popups->posts as $popup ) { |
||
| 43 | |||
| 44 | /* Count ratio */ |
||
| 45 | $limit = 0; |
||
| 46 | |||
| 47 | $types = array( |
||
| 48 | 'impression', |
||
| 49 | 'conversion' |
||
| 50 | ); |
||
| 51 | |||
| 52 | for( $count = 0; $count <= $lines; $count++ ) { |
||
| 53 | |||
| 54 | if( $limit >= $max ) |
||
| 55 | $types[1] = 'impression'; |
||
| 56 | |||
| 57 | $dtype = rand( 0, 1 ); |
||
| 58 | $dtype = $types[$dtype]; |
||
| 59 | $time = wpbo_rand_date( strtotime( 'first day of January last year', time() ), strtotime( 'last day of December this year', time() ) ); |
||
| 60 | |||
| 61 | if( $dtype === 'conversion' ) |
||
| 62 | ++$limit; |
||
| 63 | |||
| 64 | wpbo_db_insert_data( array( 'time' => $time, 'data_type' => $dtype, 'popup_id' => $popup->ID, ), false ); |
||
| 65 | |||
| 66 | } |
||
| 67 | |||
| 68 | } |
||
| 69 | |||
| 70 | } |
||
| 71 | |||
| 72 | } |
||
| 73 | |||
| 80 | } |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.