Conditions | 11 |
Paths | 9 |
Total Lines | 21 |
Code Lines | 15 |
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 |
||
71 | public function get_price( $data ) { |
||
72 | $price = get_post_meta( $this->context->id, 'price', true ); |
||
73 | $currency = 'USD'; |
||
74 | $tour_operator = tour_operator(); |
||
75 | if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
||
76 | if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
||
77 | $currency = $tour_operator->options['general']['currency']; |
||
78 | } |
||
79 | } |
||
80 | if ( false !== $price && '' !== $price ) { |
||
81 | $data['price'] = $price; |
||
82 | $data['priceCurrency'] = $currency; |
||
83 | $data['category'] = __( 'Special', 'tour-operator-specials' ); |
||
84 | $data['availability'] = 'https://schema.org/LimitedAvailability'; |
||
85 | |||
86 | $price_type = get_post_meta( $this->context->id, 'price_type', true ); |
||
87 | if ( false !== $price_type && '' !== $price_type && 'none' !== $price_type ) { |
||
88 | $data['PriceSpecification'] = lsx_to_get_price_type_label( $price_type ); |
||
89 | } |
||
90 | } |
||
91 | return $data; |
||
92 | } |
||
94 |