Code Duplication    Length = 20-20 lines in 2 locations

includes/api/class-wc-rest-products-controller.php 1 location

@@ 1022-1041 (lines=20) @@
1019
						);
1020
					}
1021
1022
				} elseif ( isset( $attribute['options'] ) ) {
1023
					// Array based.
1024
					if ( is_array( $attribute['options'] ) ) {
1025
						$values = implode( ' ' . WC_DELIMITER . ' ', array_map( 'wc_clean', $attribute['options'] ) );
1026
1027
					// Text based, separate by pipe.
1028
					} else {
1029
						$values = implode( ' ' . WC_DELIMITER . ' ', array_map( 'wc_clean', explode( WC_DELIMITER, $attribute['options'] ) ) );
1030
					}
1031
1032
					// Custom attribute - Add attribute to array and set the values.
1033
					$attributes[ sanitize_title( $attribute_name ) ] = array(
1034
						'name'         => $attribute_name,
1035
						'value'        => $values,
1036
						'position'     => isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0',
1037
						'is_visible'   => ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0,
1038
						'is_variation' => ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0,
1039
						'is_taxonomy'  => 0,
1040
					);
1041
				}
1042
			}
1043
1044
			uasort( $attributes, 'wc_product_attribute_uasort_comparison' );

includes/cli/class-wc-cli-product.php 1 location

@@ 1199-1218 (lines=20) @@
1196
						);
1197
					}
1198
1199
				} elseif ( isset( $attribute['options'] ) ) {
1200
					// Array based
1201
					if ( is_array( $attribute['options'] ) ) {
1202
						$values = implode( ' ' . WC_DELIMITER . ' ', array_map( 'wc_clean', $attribute['options'] ) );
1203
1204
					// Text based, separate by pipe
1205
					} else {
1206
						$values = implode( ' ' . WC_DELIMITER . ' ', array_map( 'wc_clean', explode( WC_DELIMITER, $attribute['options'] ) ) );
1207
					}
1208
1209
					// Custom attribute - Add attribute to array and set the values
1210
					$attributes[ $attribute_slug ] = array(
1211
						'name'         => wc_clean( $attribute['name'] ),
1212
						'value'        => $values,
1213
						'position'     => isset( $attribute['position'] ) ? absint( $attribute['position'] ) : 0,
1214
						'is_visible'   => ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0,
1215
						'is_variation' => ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0,
1216
						'is_taxonomy'  => $is_taxonomy
1217
					);
1218
				}
1219
			}
1220
1221
			uasort( $attributes, 'wc_product_attribute_uasort_comparison' );