Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1920-1922 (lines=3) @@
1917
		$sharer = new Sharing_Service();
1918
		$services = array_keys( $sharer->get_all_services() );
1919
1920
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
1921
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
1922
		}
1923
1924
		return true;
1925
	}
@@ 1703-1705 (lines=3) @@
1700
1701
			// If it's an associative array, use the keys to check that the value is among those admitted.
1702
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1703
			if ( ! in_array( $value, $enum ) ) {
1704
				return new WP_Error( 'invalid_param_value', sprintf(
1705
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1706
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1707
				) );
1708
			}
@@ 1731-1733 (lines=3) @@
1728
1729
		$modules = Jetpack::get_available_modules();
1730
1731
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1732
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1733
		}
1734
1735
		return true;
1736
	}