Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1727-1729 (lines=3) @@
1724
1725
			// If it's an associative array, use the keys to check that the value is among those admitted.
1726
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1727
			if ( ! in_array( $value, $enum ) ) {
1728
				return new WP_Error( 'invalid_param_value', sprintf(
1729
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1730
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1731
				) );
1732
			}
@@ 1755-1757 (lines=3) @@
1752
1753
		$modules = Jetpack::get_available_modules();
1754
1755
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1756
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1757
		}
1758
1759
		return true;
1760
	}
@@ 1926-1928 (lines=3) @@
1923
		$sharer = new Sharing_Service();
1924
		$services = array_keys( $sharer->get_all_services() );
1925
1926
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
1927
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
1928
		}
1929
1930
		return true;
1931
	}