Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1931-1933 (lines=3) @@
1928
1929
			// If it's an associative array, use the keys to check that the value is among those admitted.
1930
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1931
			if ( ! in_array( $value, $enum ) ) {
1932
				return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be one of %s', 'jetpack' ), $param, implode( ', ', $enum ) ) );
1933
			}
1934
		}
1935
		return true;
1936
	}
@@ 1956-1958 (lines=3) @@
1953
1954
		$modules = Jetpack::get_available_modules();
1955
1956
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1957
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1958
		}
1959
1960
		return true;
1961
	}
@@ 2092-2094 (lines=3) @@
2089
		$sharer = new Sharing_Service();
2090
		$services = array_keys( $sharer->get_all_services() );
2091
2092
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2093
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2094
		}
2095
2096
		return true;
2097
	}