Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 2014-2016 (lines=3) @@
2011
	 * @return bool|WP_Error
2012
	 */
2013
	public static function validate_alphanum( $value = '', $request, $param ) {
2014
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2015
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2016
		}
2017
		return true;
2018
	}
2019
@@ 2032-2034 (lines=3) @@
2029
	 * @return bool|WP_Error
2030
	 */
2031
	public static function validate_verification_service( $value = '', $request, $param ) {
2032
		if ( ! empty( $value ) && ! ( is_string( $value ) && ( preg_match( '/^[a-z0-9_-]+$/i', $value ) || preg_match( '#^<meta name="([a-z0-9_\-.:]+)?" content="([a-z0-9_-]+)?" />$#i', $value ) ) ) ) {
2033
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
2034
		}
2035
		return true;
2036
	}
2037
@@ 2174-2176 (lines=3) @@
2171
	 * @return bool|WP_Error
2172
	 */
2173
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2174
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2175
			return new WP_Error( 'invalid_param', sprintf( esc_html__( "%s must be a string prefixed with 'custom-' and followed by a numeric ID.", 'jetpack' ), $param ) );
2176
		}
2177
2178
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2179
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2203-2205 (lines=3) @@
2200
	 * @return bool|WP_Error
2201
	 */
2202
	public static function validate_twitter_username( $value = '', $request, $param ) {
2203
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2204
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2205
		}
2206
		return true;
2207
	}
2208