| Conditions | 6 |
| Paths | 2 |
| Total Lines | 53 |
| 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 | public function valueProvider( $stringlyTyped = true ) { |
||
| 45 | $values = [ |
||
| 46 | 'empty' => [ |
||
| 47 | [ '100px', true, '100px' ], |
||
| 48 | [ '100', true, '100px' ], |
||
| 49 | [ 42, true, '42px' ], |
||
| 50 | [ 42.5, true, '42.5px' ], |
||
| 51 | [ 'over9000', false ], |
||
| 52 | [ 'yes', false ], |
||
| 53 | [ 'auto', false ], |
||
| 54 | [ '100%', false ], |
||
| 55 | ], |
||
| 56 | 'values' => [ |
||
| 57 | [ 1, true, '1px' ], |
||
| 58 | // array( 2, false ), |
||
| 59 | [ 'yes', false ], |
||
| 60 | [ 'no', false ], |
||
| 61 | ], |
||
| 62 | 'auto' => [ |
||
| 63 | [ 'auto', true, 'auto' ], |
||
| 64 | ], |
||
| 65 | 'allunits' => [ |
||
| 66 | [ '100%', true, '100%' ], |
||
| 67 | [ '100em', true, '100em' ], |
||
| 68 | [ '100ex', true, '100ex' ], |
||
| 69 | [ '101%', false ], |
||
| 70 | ], |
||
| 71 | 'bounds' => [ |
||
| 72 | [ '30%', true, '30%' ], |
||
| 73 | [ '20%', false ], |
||
| 74 | [ '40%', false ], |
||
| 75 | [ '100px', true, '100px' ], |
||
| 76 | [ '100ex', true, '100ex' ], |
||
| 77 | [ '10px', false ], |
||
| 78 | [ '9001ex', false ], |
||
| 79 | ], |
||
| 80 | ]; |
||
| 81 | |||
| 82 | if ( $stringlyTyped ) { |
||
| 83 | foreach ( $values as &$set ) { |
||
| 84 | foreach ( $set as &$value ) { |
||
| 85 | if ( is_int( $value[0] ) || is_float( $value[0] ) ) { |
||
| 86 | $value[0] = (string)$value[0]; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | // $values['empty'][] = array( 42, false ); |
||
| 92 | // $values['empty'][] = array( 42.5, false ); |
||
| 93 | } |
||
| 94 | |||
| 95 | return $values; |
||
| 96 | } |
||
| 97 | |||
| 107 |