Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2572-2574 (lines=3) @@
2569
2570
			// If it's an associative array, use the keys to check that the value is among those admitted.
2571
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
2572
			if ( ! in_array( $value, $enum ) ) {
2573
				return new WP_Error( 'invalid_param_value', sprintf(
2574
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
2575
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
2576
				) );
2577
			}
@@ 2600-2602 (lines=3) @@
2597
2598
		$modules = Jetpack::get_available_modules();
2599
2600
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
2601
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
2602
		}
2603
2604
		return true;
2605
	}
@@ 2789-2791 (lines=3) @@
2786
		$sharer = new Sharing_Service();
2787
		$services = array_keys( $sharer->get_all_services() );
2788
2789
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2790
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2791
		}
2792
2793
		return true;
2794
	}