Code Duplication    Length = 3-3 lines in 3 locations

_inc/lib/class.core-rest-api-endpoints.php 3 locations

@@ 2612-2614 (lines=3) @@
2609
2610
			// If it's an associative array, use the keys to check that the value is among those admitted.
2611
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
2612
			if ( ! in_array( $value, $enum ) ) {
2613
				return new WP_Error( 'invalid_param_value', sprintf(
2614
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
2615
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
2616
				) );
2617
			}
@@ 2640-2642 (lines=3) @@
2637
2638
		$modules = Jetpack::get_available_modules();
2639
2640
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
2641
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
2642
		}
2643
2644
		return true;
2645
	}
@@ 2829-2831 (lines=3) @@
2826
		$sharer = new Sharing_Service();
2827
		$services = array_keys( $sharer->get_all_services() );
2828
2829
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2830
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2831
		}
2832
2833
		return true;
2834
	}