Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1743-1745 (lines=3) @@
1740
1741
			// If it's an associative array, use the keys to check that the value is among those admitted.
1742
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1743
			if ( ! in_array( $value, $enum ) ) {
1744
				return new WP_Error( 'invalid_param_value', sprintf(
1745
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1746
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1747
				) );
1748
			}
@@ 1771-1773 (lines=3) @@
1768
1769
		$modules = Jetpack::get_available_modules();
1770
1771
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1772
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1773
		}
1774
1775
		return true;
1776
	}
@@ 1960-1962 (lines=3) @@
1957
		$sharer = new Sharing_Service();
1958
		$services = array_keys( $sharer->get_all_services() );
1959
1960
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
1961
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
1962
		}
1963
1964
		return true;
1965
	}