| Conditions | 15 |
| Paths | 192 |
| Total Lines | 44 |
| Code Lines | 31 |
| 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 |
||
| 24 | protected function process_output( $output, $value ) { |
||
| 25 | |||
| 26 | $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
||
| 27 | $output['element'] = ( isset( $output['element'] ) ) ? $output['element'] : 'body'; |
||
| 28 | $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
||
| 29 | $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
||
| 30 | |||
| 31 | if ( ! isset( $value['variant'] ) || ! isset( $value['font-weight'] ) || ! isset( $value['font-style'] ) ) { |
||
| 32 | $value = Kirki_Field_Typography::sanitize( $value ); |
||
| 33 | $this->value = $value; |
||
| 34 | } |
||
| 35 | |||
| 36 | $properties = array( |
||
| 37 | 'font-family', |
||
| 38 | 'font-size', |
||
| 39 | 'font-weight', |
||
| 40 | 'font-style', |
||
| 41 | 'letter-spacing', |
||
| 42 | 'word-spacing', |
||
| 43 | 'line-height', |
||
| 44 | 'text-align', |
||
| 45 | 'text-transform', |
||
| 46 | 'color', |
||
| 47 | ); |
||
| 48 | |||
| 49 | foreach ( $properties as $property ) { |
||
| 50 | if ( ! isset( $value[ $property ] ) || '' === $value[ $property ] ) { |
||
| 51 | continue; |
||
| 52 | } |
||
| 53 | if ( isset( $output['choice'] ) && $output['choice'] !== $property ) { |
||
| 54 | continue; |
||
| 55 | } |
||
| 56 | |||
| 57 | $property_value = $this->process_property_value( $property, $value[ $property ] ); |
||
| 58 | if ( 'font-family' === $property ) { |
||
| 59 | $value['font-backup'] = ( isset( $value['font-backup'] ) ) ? $value['font-backup'] : ''; |
||
| 60 | $property_value = $this->process_property_value( $property, array( |
||
|
|
|||
| 61 | $value['font-family'], |
||
| 62 | $value['font-backup'], |
||
| 63 | ) ); |
||
| 64 | } |
||
| 65 | $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix']; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: