Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 20 | class Jetpack_WooCommerce_Analytics_Utils { |
||
| 21 | /** |
||
| 22 | * Gets product categories or varation attributes as a formatted concatenated string |
||
| 23 | * |
||
| 24 | * @param array $product WC_Product. |
||
| 25 | * @return string |
||
| 26 | */ |
||
| 27 | View Code Duplication | public static function get_product_categories_concatenated( $product ) { |
|
| 51 | } |
||
| 52 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.