Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 2098-2100 (lines=3) @@
2095
		$sharer = new Sharing_Service();
2096
		$services = array_keys( $sharer->get_all_services() );
2097
2098
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2099
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2100
		}
2101
2102
		return true;
2103
	}
@@ 1881-1883 (lines=3) @@
1878
1879
			// If it's an associative array, use the keys to check that the value is among those admitted.
1880
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1881
			if ( ! in_array( $value, $enum ) ) {
1882
				return new WP_Error( 'invalid_param_value', sprintf(
1883
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1884
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1885
				) );
1886
			}
@@ 1986-1988 (lines=3) @@
1983
	 */
1984
	public static function validate_sharing_show( $value, $request, $param ) {
1985
		$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' );
1986
		if ( ! is_array( $value ) ) {
1987
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array of post types.', 'jetpack' ), $param ) );
1988
		}
1989
		if ( ! array_intersect( $views, $value ) ) {
1990
			return new WP_Error( 'invalid_param', sprintf(
1991
				/* Translators: first variable is the name of a parameter passed to endpoint holding the post type where Sharing will be displayed, the second is a list of post types where Sharing can be displayed */
@@ 1989-1991 (lines=3) @@
1986
		if ( ! is_array( $value ) ) {
1987
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array of post types.', 'jetpack' ), $param ) );
1988
		}
1989
		if ( ! array_intersect( $views, $value ) ) {
1990
			return new WP_Error( 'invalid_param', sprintf(
1991
				/* Translators: first variable is the name of a parameter passed to endpoint holding the post type where Sharing will be displayed, the second is a list of post types where Sharing can be displayed */
1992
				esc_html__( '%1$s must be %2$s.', 'jetpack' ), $param, join( ', ', $views )
1993
			) );
1994
		}